summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-03 08:26:19 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-03 08:26:19 +0000
commita2c3f4546c0c32c3d40c52c81b5fd5131ba19145 (patch)
tree34a20016e47a4de2c8eb44c2b6190e4f73aebad2
parent7a7471c7e4c95b758da192622f7476dce8f0faf8 (diff)
Tag 2.0 M4 RC2
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@832340 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--tags/java/sca/2.0-M4-RC2/BUILDING44
-rw-r--r--tags/java/sca/2.0-M4-RC2/CHANGES81
-rw-r--r--tags/java/sca/2.0-M4-RC2/LICENSE485
-rw-r--r--tags/java/sca/2.0-M4-RC2/NOTICE59
-rw-r--r--tags/java/sca/2.0-M4-RC2/README19
-rw-r--r--tags/java/sca/2.0-M4-RC2/RELEASE_NOTES73
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml110
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/pom.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml153
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/pom.xml51
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml182
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel66
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml44
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml154
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml230
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp37
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp22
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp35
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml42
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml154
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml44
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml124
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties77
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties51
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp29
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp42
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp32
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml68
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html27
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/pom.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml42
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml143
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp36
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/manifests/axiom-api-1.2.7.MF48
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/manifests/woden-impl-dom-1.0M8.MF229
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/pom.xml135
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/bin.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/src.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-common.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-launcher.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-modules.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-samples.xml86
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/INSTALL24
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/LICENSE1673
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/NOTICE85
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/README42
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/default.config22
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/osgi.config21
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.bat83
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.sh54
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/unmanaged.config21
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/pom.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/README.txt8
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/pom.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/download-tomcat/pom.xml63
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/pom.xml47
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite30
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp36
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/pom.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite28
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/pom.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/pom.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF24
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/NOTICE7
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/pom.xml70
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java170
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java185
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF11
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/pom.xml63
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java318
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/pom.xml101
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/assembly/war.xml95
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE1117
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE79
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp74
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/all/pom.xml98
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/api/pom.xml58
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/core/pom.xml230
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/ejava/pom.xml133
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/pom.xml48
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/process/pom.xml57
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/web20/pom.xml81
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/webapp/pom.xml96
-rw-r--r--tags/java/sca/2.0-M4-RC2/features/webservice/pom.xml122
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/pom.xml288
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl87
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel84
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl94
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/log4j.properties36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/pom.xml178
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel66
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/log4j.properties36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/pom.xml270
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel78
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl94
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/log4j.properties36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/bpel/pom.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/pom.xml119
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1a.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10.composite62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10a.composite61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/service3.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11a.composite64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/service3.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12.composite58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12a.composite64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13.composite58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13a.composite64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2a.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3a.composite48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4a.composite48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5.composite46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5a.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenarios.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6a.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenarios.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7a.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenarios.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8a.composite50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenarios.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9.composite60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9a.composite61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java814
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java319
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/pom.xml58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java201
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/CallBackApiTest.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/pom.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/pom.xml58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/CallBackBasicTest.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java186
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java195
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorClient.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/Calculator.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType43
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/component-type/src/test/java/calculator/CalculatorTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/pom.xml46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/calculator/CalculatorService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jarbin0 -> 2380 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jarbin0 -> 4655 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository3/contribution.zipbin0 -> 5478 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/pom.xml67
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/hello.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/pom.xml67
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/pom.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/pom.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java127
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/pom.xml102
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/store.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java137
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/pom.xml56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-zip/pom.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/calculator/CalculatorService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/resources/repository/contribution.zipbin0 -> 6395 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/build.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/pom.xml138
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/build.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/pom.xml82
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/build.xml51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/pom.xml81
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/build.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/pom.xml82
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/pom.xml42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/pom.xml49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/pom.xml124
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/pom.xml216
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/pom.xml188
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/pom.xml130
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/pom.xml188
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/pom.xml124
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld/pom.xml121
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/pom.xml68
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/EndpointsTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/Utils.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/helloworld.composite116
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/nested.composite30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java115
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/resources/ExceptionTest.composite41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/pom.xml80
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorService.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java178
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBean.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReference.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF3
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config3
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties18
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF3
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/spring-context.jarbin0 -> 1454 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InterfacesTest.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java133
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuote.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuoteImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/resources/StockQuote.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/pom.xml70
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/selectors/selectors.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/jndi.properties40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/client.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/tempq.composite50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/client.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/service.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions.xml28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions/definitions.composite39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/pom.xml90
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/exceptions/service.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/jndi.properties40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java212
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/client.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/service.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/client.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/service.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite94
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl139
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README3
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl129
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl368
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite80
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl153
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README3
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite52
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl139
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/service.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/pom.xml71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/nulls.composite57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/pom.xml68
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/properties/properties.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/client.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/service.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/client.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/service.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/pom.xml70
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite69
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite65
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/selectors/selectors.composite68
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/pom.xml71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsClient.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsService.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/pom.xml71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java904
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/jndi.properties38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/ttl.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/jndi.properties39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/service.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/pom.xml44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/pom.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/pom.xml49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/pom.xml48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/pom.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/pom.xml58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java92
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java292
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/build.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client-config.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/pom.xml117
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server-config.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/resources/OperationOverload.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java98
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/pom.xml59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Customer.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/LoggingMessages.properties16
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/definitions.xml46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Payment.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/pom.xml167
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/pom.xml74
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/package-info.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/ConstructorPropertyInjection.composite39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/Outer.composite43
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/OuterPropertyTest.composite42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/PropertyTest.composite260
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/customer.xsd30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/fileProperty.txt21
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/manyValuesFileProperty.txt23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/mySimpleService.composite40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcProps.txt22
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcprops.xsd55
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java422
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/pom.xml61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite52
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite52
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/pom.xml52
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/AutoWiredReferencesTest.composite61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/InnerReferencesTest.composite51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/ManualWiredReferencesTest.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/pom.xml46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/Helloworld.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scdl/pom.xml79
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/resources/test.composite51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scopes/pom.xml54
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/resources/scopes.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/pom.xml66
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java297
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeA/CompositeA.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeB/CompositeB.composite46
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite48
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java139
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/ServicesTest.composite70
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/main/resources/WireTest.composite39
-rw-r--r--tags/java/sca/2.0-M4-RC2/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/META-INF/MANIFEST.MF70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/pom.xml80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java782
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java378
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java1065
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java252
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java148
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java171
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java230
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java250
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java392
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java510
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml242
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java191
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java130
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java190
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java109
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java230
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java286
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite127
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml206
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml207
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml204
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/LICENSE337
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/META-INF/MANIFEST.MF15
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/NOTICE38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/pom.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd402
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd204
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd195
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd137
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd141
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd318
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd173
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd183
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd534
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd101
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/META-INF/MANIFEST.MF62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/pom.xml45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java166
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java141
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java132
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java146
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java189
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java118
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java395
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java186
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java119
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java167
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java185
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java202
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java250
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java168
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java307
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java119
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java139
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java209
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java219
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java390
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java328
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java284
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java190
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java152
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java160
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java146
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java168
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java145
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties327
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java170
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java395
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/MANIFEST.MF48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/pom.xml214
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java515
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java914
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java165
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java178
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java118
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java221
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java159
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java259
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java213
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java295
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java433
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java387
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java204
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java135
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java98
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gifbin0 -> 14205 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpgbin0 -> 21373 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/MANIFEST.MF21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/pom.xml54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/META-INF/MANIFEST.MF41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/pom.xml169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java365
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java811
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java154
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java92
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java338
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java483
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java209
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java157
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java189
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/Customer.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/resources/account/account.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/META-INF/MANIFEST.MF28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/pom.xml60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java180
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java167
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/META-INF/MANIFEST.MF27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/pom.xml104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java453
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java212
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java904
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java164
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/content/test.html21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/test.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/testCache.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/META-INF/MANIFEST.MF24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/pom.xml62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java257
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/META-INF/MANIFEST.MF38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/pom.xml111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java141
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java167
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java234
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java190
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java119
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java287
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java166
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java228
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java282
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java230
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java270
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java134
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java185
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java174
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java202
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java174
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java194
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java141
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java119
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java123
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java109
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java115
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java115
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java229
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/client.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/service.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/META-INF/MANIFEST.MF64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/pom.xml51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java974
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java1541
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java130
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java206
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java773
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java438
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/pom.xml97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java165
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/jquery.html51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/META-INF/MANIFEST.MF19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/pom.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/NOTICE11
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/pom.xml143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java314
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js493
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java203
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/META-INF/MANIFEST.MF18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/pom.xml46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/META-INF/MANIFEST.MF32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/pom.xml79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/META-INF/MANIFEST.MF19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/pom.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/pom.xml96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java120
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java163
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/pom.xml72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java240
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/Calculator.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/pom.xml139
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java156
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/META-INF/MANIFEST.MF158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/pom.xml416
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java302
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java461
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java817
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java356
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java336
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java115
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java231
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml504
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list1
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.marbin0 -> 2796 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list0
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java133
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/package-info.java21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.java24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml101
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jksbin0 -> 1379 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml323
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jksbin0 -> 1379 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml203
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jksbin0 -> 1379 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/pom.xml84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java342
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java887
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java305
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java512
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/META-INF/MANIFEST.MF43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/pom.xml95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java214
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java299
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java223
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java382
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/META-INF/MANIFEST.MF30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/pom.xml55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java703
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java379
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java1244
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java173
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java528
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java534
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java839
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java184
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java379
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java216
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java276
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java134
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java139
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odgbin0 -> 15518 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.pngbin0 -> 4041817 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml207
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/META-INF/MANIFEST.MF24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/pom.xml55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java149
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java586
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/META-INF/MANIFEST.MF58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/pom.xml98
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java152
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java230
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java244
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java498
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java256
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java368
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java310
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java404
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java348
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java279
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java482
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java858
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java258
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java531
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java613
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java207
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java120
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/META-INF/MANIFEST.MF23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/pom.xml72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java152
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java200
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/META-INF/MANIFEST.MF61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/pom.xml63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java167
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java173
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java386
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java152
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java165
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java492
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java325
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java292
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java320
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java435
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java283
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java259
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java145
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java406
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java285
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java179
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java127
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java245
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-java-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-validation-messages.properties34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java262
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java137
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/deployables/sample-calculator.jarbin0 -> 26901 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/repository/sample-calculator.jarbin0 -> 29164 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.composite22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.ext0
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/META-INF/MANIFEST.MF46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/pom.xml90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java270
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java251
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java188
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java109
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/META-INF/MANIFEST.MF50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/pom.xml71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/doc/Context Model.emx673
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java127
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java498
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java127
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java207
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/META-INF/MANIFEST.MF69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/pom.xml89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java845
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java208
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java98
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java101
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java787
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java154
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java496
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java118
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java481
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java149
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java202
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java268
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java195
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java537
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java177
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java313
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java236
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java156
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java299
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java196
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java195
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java228
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java167
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/endpoint-validation-messages.properties22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java154
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java240
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java227
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/META-INF/MANIFEST.MF16
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/pom.xml38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java159
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/pom.xml112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java251
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xml51
-rwxr-xr-xtags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xsd137
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/order.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/pom.xml175
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java140
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java191
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java123
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java246
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/META-INF/MANIFEST.MF55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/pom.xml175
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java378
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java561
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java482
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java302
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java244
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java151
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java166
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java299
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java148
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java238
-rwxr-xr-xtags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/resources/ipo.xsd144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/LICENSE202
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/META-INF/MANIFEST.MF33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/pom.xml124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java176
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java137
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java170
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java92
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/resources/ipo.xsd136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/LICENSE244
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/META-INF/MANIFEST.MF73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/pom.xml97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java261
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java321
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseDataBinding.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseTransformer.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java452
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java581
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java401
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java945
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java98
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java262
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java329
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java165
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/LRUCache.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java300
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java138
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java123
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java188
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java137
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/META-INF/MANIFEST.MF49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/pom.xml76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java191
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java160
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java545
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorld.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java135
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/META-INF/MANIFEST.MF18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/pom.xml63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java157
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/itest/nodes/Helloworld.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jarbin0 -> 4708 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jarbin0 -> 4515 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/META-INF/MANIFEST.MF19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/README1
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/TODO3
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/pom.xml47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/java/org/apache/tuscany/sca/endpoint/dht/OverlayEndpointRegistry.java327
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/META-INF/MANIFEST.MF29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/pom.xml47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java1564
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java453
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/NOTICE5
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/pom.xml66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java319
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java155
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/resources/test-bundle.jarbin0 -> 1797 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/META-INF/MANIFEST.MF20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/pom.xml31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java191
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java155
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java219
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java208
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java251
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java292
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java244
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java225
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java1357
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java118
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java103
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/META-INF/MANIFEST.MF25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/pom.xml74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/HttpServiceWrapper.java145
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java275
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/ServletRequestDispatcher.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/java/org/apache/tuscany/sca/http/osgi/OSGiServletHostTestCase.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/content/test.html23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/META-INF/MANIFEST.MF21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/pom.xml46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java198
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java120
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/META-INF/MANIFEST.MF29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/pom.xml69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java519
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java332
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/content/test.html21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/META-INF/MANIFEST.MF29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/pom.xml57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyDefaultServlet.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyServer.java520
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/java/org/apache/tuscany/sca/http/jetty7/JettyServerTestCase.java335
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/content/test.html21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/tuscany.keyStorebin0 -> 1265 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/META-INF/MANIFEST.MF17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/pom.xml39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java170
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/META-INF/MANIFEST.MF25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/NOTICE7
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java188
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java109
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java312
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/LICENSE251
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/NOTICE17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/pom.xml495
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java233
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java233
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java563
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java373
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java756
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java177
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java286
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/log4j.properties36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/LICENSE251
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/META-INF/MANIFEST.MF34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/NOTICE17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/pom.xml64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java127
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java401
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java354
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java452
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java132
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java118
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/META-INF/MANIFEST.MF62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/pom.xml57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java327
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java120
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java374
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java207
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java176
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java182
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme449
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java120
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java189
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/META-INF/MANIFEST.MF47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/pom.xml99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java222
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java184
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java92
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java162
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java577
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java222
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java662
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java303
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java274
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java238
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java334
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractService.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java206
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java174
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java188
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java164
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java216
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java330
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java583
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java157
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java428
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java304
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java310
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java128
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java197
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java219
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java180
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml113
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/LICENSE203
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/pom.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java266
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java210
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/LICENSE203
-rwxr-xr-xtags/java/sca/2.0-M4-RC2/modules/implementation-osgi/META-INF/MANIFEST.MF36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java186
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java116
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java51
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java174
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java342
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java190
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java191
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java139
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/osgitest.composite35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/META-INF/MANIFEST.MF26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/README9
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/pom.xml70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java115
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java161
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java164
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java189
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java133
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.handlers1
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.schemas1
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/org/springframework/sca/xml/spring-sca.xsd84
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/META-INF/MANIFEST.MF55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/README9
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/pom.xml69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java228
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java660
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java1153
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java134
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java230
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/LICENSE241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/META-INF/MANIFEST.MF32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/NOTICE12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/pom.xml68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientImplementationProvider.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientProviderFactory.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java273
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/LICENSE241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/META-INF/MANIFEST.MF30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/NOTICE12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/pom.xml96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java133
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory21
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/META-INF/MANIFEST.MF30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/pom.xml73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java135
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/META-INF/MANIFEST.MF50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/pom.xml281
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java542
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java280
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java147
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java276
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java403
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java393
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java238
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl171
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/META-INF/MANIFEST.MF43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/pom.xml59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java32
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java90
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java139
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java278
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java173
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java210
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java346
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties27
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java317
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java123
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java119
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/META-INF/MANIFEST.MF48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/pom.xml87
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java140
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java79
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java284
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java187
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java607
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java221
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java382
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java535
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java85
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java77
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd136
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl49
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/name.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/launcher/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/launcher/META-INF/MANIFEST.MF28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/launcher/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/launcher/pom.xml35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java325
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/META-INF/MANIFEST.MF15
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/pom.xml33
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java342
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java181
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java98
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/LICENSE241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/META-INF/MANIFEST.MF20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/NOTICE12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/pom.xml76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/META-INF/MANIFEST.MF20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/pom.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java160
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java446
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java113
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java155
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java186
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/META-INF/MANIFEST.MF54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/pom.xml121
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java129
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java143
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java142
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointDescription.java385
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointListener.java112
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointPermission.java938
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ExportRegistration.java61
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ImportRegistration.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteConstants.java155
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdmin.java110
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminEvent.java149
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminListener.java16
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java82
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java474
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java92
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java204
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java125
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java95
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java289
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java410
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java280
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java124
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java75
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java156
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java99
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java361
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite70
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/META-INF/MANIFEST.MF42
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/pom.xml108
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java160
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java236
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java398
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java369
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java86
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java107
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/META-INF/MANIFEST.MF23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/pom.xml126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java173
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java655
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java254
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java160
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java376
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java217
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java1345
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile185
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF2
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF229
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java50
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java100
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java67
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/META-INF/MANIFEST.MF17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/pom.xml64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java180
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java169
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java303
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java567
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java130
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/META-INF/MANIFEST.MF30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/pom.xml53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java97
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java171
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java135
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions17
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/META-INF/MANIFEST.MF64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/pom.xml52
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java123
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java80
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java101
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java102
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java150
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java83
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java89
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java131
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java91
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java81
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java71
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java148
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/policy-security-validation-messages.properties22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/pom.xml130
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessor.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestModelResolver.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java74
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessorTestCase.java111
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/pom.xml166
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/LICENSE243
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/META-INF/MANIFEST.MF18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/NOTICE13
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/pom.xml35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java122
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/SCARuntimeException.java41
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java22
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java58
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java46
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java53
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java126
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinder.java241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/META-INF/MANIFEST.MF16
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/pom.xml47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java59
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory2
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/LICENSE241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/NOTICE12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/pom.xml60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java298
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java57
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/LICENSE241
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/META-INF/MANIFEST.MF31
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/NOTICE12
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/pom.xml65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/IContextLocator.java60
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyComponentInjector.java158
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyFieldValueFactory.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyInjector.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/META-INF/MANIFEST.MF47
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/pom.xml65
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java117
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java232
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java106
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java328
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver19
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory18
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties23
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java96
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/greeting.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/name.xsd29
-rw-r--r--tags/java/sca/2.0-M4-RC2/pom.xml832
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/README232
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/README97
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/build.xml67
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.pngbin0 -> 20552 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.svg329
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/pom.xml89
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java26
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/Calculator.composite59
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/build-common.xml102
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/README97
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/build.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.pngbin0 -> 20552 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.svg329
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/pom.xml84
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/resources/Calculator.composite54
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/META-INF/MANIFEST.MF19
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/README97
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/build.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/pom.xml116
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java54
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java69
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/resources/Calculator.composite54
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java55
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/README138
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/build.xml84
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.pngbin0 -> 23615 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.svg412
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/pom.xml82
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java49
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java39
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite42
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java52
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/README147
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/build.xml76
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.pngbin0 -> 20814 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.svg330
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/pom.xml67
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java40
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java68
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java30
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite53
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/README97
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/build.xml65
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.pngbin0 -> 20552 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.svg329
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/pom.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorClient.java48
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java72
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/Calculator.composite49
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java63
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF22
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType47
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/README183
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/pom.xml141
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java88
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/META-INF/MANIFEST.MF20
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/calculator-component.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType54
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite45
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/README155
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/dosgi-calculator.pngbin0 -> 85103 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/pom.xml146
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java76
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java132
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml24
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml40
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/README183
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/pom.xml141
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java94
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java104
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/LICENSE205
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/NOTICE6
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml61
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml32
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/README155
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/dosgi-calculator.pngbin0 -> 85103 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/pom.xml146
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java114
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java93
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java132
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java43
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java144
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java105
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/README151
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/build.xml95
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.pngbin0 -> 8897 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.svg179
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/pom.xml115
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.bpel78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/log4j.properties35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java65
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/README96
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/build.xml59
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.pngbin0 -> 20552 bytes
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.svg329
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/pom.xml65
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java62
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java70
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/resources/Calculator.composite54
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java73
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/logging.properties25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/pom.xml78
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/pom.xml130
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel66
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl82
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/README131
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/pom.xml80
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml48
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite44
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml66
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp41
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/pom.xml62
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite36
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/hello.html51
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/pom.xml69
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java56
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml51
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml191
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp40
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp23
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/pom.xml62
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml41
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/README37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/pom.xml111
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java108
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java13
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java44
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/resources/rest.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html75
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml26
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/style.css22
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/target/classes/rest.composite37
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/pom.xml61
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java27
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java64
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml44
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/hello.html46
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/pom.xml72
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java33
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java45
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties57
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties31
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp26
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp39
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml61
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/index.html24
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/pom.xml83
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java28
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html48
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java66
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java35
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java47
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite34
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml50
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/pom.xml62
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java25
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java38
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite29
-rw-r--r--tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml37
3928 files changed, 342105 insertions, 0 deletions
diff --git a/tags/java/sca/2.0-M4-RC2/BUILDING b/tags/java/sca/2.0-M4-RC2/BUILDING
new file mode 100644
index 0000000000..9993ef4b96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/BUILDING
@@ -0,0 +1,44 @@
+Building the Apache Tuscany SCA source distribution
+===================================================
+
+Initial Setup
+-------------
+
+1) Install J2SE 5.0 SDK, which can be downloaded from
+ http://java.sun.com/j2se/1.5.0/download.jsp. Use version of 1.5.0_06 JDK or higher.
+
+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, 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/tags/java/sca/2.0-M4-RC2/CHANGES b/tags/java/sca/2.0-M4-RC2/CHANGES
new file mode 100644
index 0000000000..7e4fb5eccb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/CHANGES
@@ -0,0 +1,81 @@
+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/tags/java/sca/2.0-M4-RC2/LICENSE b/tags/java/sca/2.0-M4-RC2/LICENSE
new file mode 100644
index 0000000000..ddd30126af
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/NOTICE b/tags/java/sca/2.0-M4-RC2/NOTICE
new file mode 100644
index 0000000000..0caf950bab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/NOTICE
@@ -0,0 +1,59 @@
+Apache Tuscany
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed at
+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
+
+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.
+
+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 specification License
+with the following copyright:
+
+Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+OASIS trademark, IPR and other policies apply.
+
+This product includes software under the W3C(c) Software License
+with the following copyright:
+
+Copyright (c) 2008 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(c) 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 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/tags/java/sca/2.0-M4-RC2/README b/tags/java/sca/2.0-M4-RC2/README
new file mode 100644
index 0000000000..0a7459ec12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/README
@@ -0,0 +1,19 @@
+Apache Tuscany SCA 2.0-M4 November 2009 README
+==============================================
+
+Welcome to the Tuscany SCA 2.0-M4 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.
+
+
+
+
+
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/RELEASE_NOTES b/tags/java/sca/2.0-M4-RC2/RELEASE_NOTES
new file mode 100644
index 0000000000..7a75ab7cc3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/RELEASE_NOTES
@@ -0,0 +1,73 @@
+Apache Tuscany SCA 2.0-M4 November 2009 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-M4 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
+ 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.
+
+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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1e2a0fbb4d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/pom.xml
new file mode 100644
index 0000000000..4af0007bc2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..46c5cd6dca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..69c3fb5ac9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..4260b840c3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</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-M4</tuscany.version>
+ </properties>
+ #end
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..26237c105c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..d705564334
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8608a99897
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sample="http://${package}">
+ <deployable composite="sample:${artifactId}"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..aacf93e66a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/pom.xml
new file mode 100644
index 0000000000..4490392088
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml
new file mode 100644
index 0000000000..a672d2920d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b5be2573dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/pom.xml
new file mode 100644
index 0000000000..152c28bb5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..46c5cd6dca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..c17535e802
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..175da3ca4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</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-M4</tuscany.version>
+ </properties>
+ #end
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java
new file mode 100644
index 0000000000..48b62dbb6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java
new file mode 100644
index 0000000000..4b25553893
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8608a99897
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sample="http://${package}">
+ <deployable composite="sample:${artifactId}"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite b/tags/java/sca/2.0-M4-RC2/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite
new file mode 100644
index 0000000000..af2ed294f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/pom.xml
new file mode 100644
index 0000000000..c08c27ef5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/pom.xml
new file mode 100644
index 0000000000..2398aaafe1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..47c2f5dc10
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..c466a1b3f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..27fd12ee55
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</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-M4</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+ #end
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..a99cc7b032
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..53e77c5be0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..46cf381577
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..aa73578a36
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..7aeaf81b33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/pom.xml
new file mode 100644
index 0000000000..03c6039680
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..f15a12fb88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..b5295d8a73
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..0b47fea538
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</tuscany.version>
+ <myfaces.version>1.5</myfaces.version>
+ <jetty.version>6.1.4</jetty.version>
+ </properties>
+ #end
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java
new file mode 100644
index 0000000000..e38c84feda
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
new file mode 100644
index 0000000000..d6cb7bbcf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..ec9bfd7221
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..847625fcf4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp
new file mode 100644
index 0000000000..4a3197ec4f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp
new file mode 100644
index 0000000000..768aa2408b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp
new file mode 100644
index 0000000000..1c096f66c6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/pom.xml
new file mode 100644
index 0000000000..e86e5d321a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..450e33afd5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..1bf4353502
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..d55a40bb11
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</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-M4</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..2491816adc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..3527edcd6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..7ccd63ce5d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9729ca6823
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ae84237c4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/pom.xml
new file mode 100644
index 0000000000..d08c53f553
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..f15a12fb88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..b5295d8a73
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..bb3732cfce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</tuscany.version>
+ <stripes.version>1.5</stripes.version>
+ <jetty.version>6.1.4</jetty.version>
+ </properties>
+ #end
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java
new file mode 100644
index 0000000000..d6cb7bbcf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..390b424d24
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties
new file mode 100644
index 0000000000..6567f21ce1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..e2fd1997c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..40896b1473
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html
new file mode 100644
index 0000000000..a350f1e68a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..29e03eb396
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/pom.xml
new file mode 100644
index 0000000000..25b743a218
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000000..c132fa0364
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml
new file mode 100644
index 0000000000..7794570626
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000000..48c34e55a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</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-M4</tuscany.version>
+ <jetty.version>6.1.18</jetty.version>
+ </properties>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java
new file mode 100644
index 0000000000..df80303778
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java
new file mode 100644
index 0000000000..47501efb9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..a90973d6f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a7c7d2251e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9729ca6823
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/manifests/axiom-api-1.2.7.MF b/tags/java/sca/2.0-M4-RC2/distribution/all/manifests/axiom-api-1.2.7.MF
new file mode 100644
index 0000000000..400fdc58e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/manifests/axiom-api-1.2.7.MF
@@ -0,0 +1,48 @@
+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
+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/tags/java/sca/2.0-M4-RC2/distribution/all/manifests/woden-impl-dom-1.0M8.MF b/tags/java/sca/2.0-M4-RC2/distribution/all/manifests/woden-impl-dom-1.0M8.MF
new file mode 100644
index 0000000000..b3e9d79d28
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/pom.xml
new file mode 100644
index 0000000000..94023a4851
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/pom.xml
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-domain-node</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.0.5</version>
+ <executions>
+ <execution>
+ <id>distribution-modules</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>generate-modules</goal>
+ </goals>
+ <configuration>
+ <targetDirectory>target/modules</targetDirectory>
+ <useDistributionName>false</useDistributionName>
+ <generateManifestJar>true</generateManifestJar>
+ <artifactManifests>
+ <artifactManifest>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.7</version>
+ <manifestFile>${basedir}/manifests/axiom-api-1.2.7.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>
+ <artifactManifest>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>*</artifactId>
+ <version>*</version>
+ </artifactManifest>
+ </artifactManifests>
+ </configuration>
+ </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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/bin.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/bin.xml
new file mode 100644
index 0000000000..51033a5e1d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/bin.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.
+-->
+<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-modules.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-samples.xml</componentDescriptor>
+ <componentDescriptor>src/main/components/bin-launcher.xml</componentDescriptor>
+ </componentDescriptors>
+</assembly>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/src.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/src.xml
new file mode 100644
index 0000000000..0bb6503560
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/assembly/src.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.
+-->
+<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>
+ </excludes>
+ </fileSet>
+ </fileSets>
+
+</assembly>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-common.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-common.xml
new file mode 100644
index 0000000000..b5b7111096
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-launcher.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-launcher.xml
new file mode 100644
index 0000000000..018e041d38
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-launcher.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.
+-->
+<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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-modules.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-modules.xml
new file mode 100644
index 0000000000..89de329d86
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-modules.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.
+-->
+<component>
+ <fileSets>
+
+ <fileSet>
+ <directory>target</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>modules/**/*</include>
+ <include>features/**/*</include>
+ </includes>
+ </fileSet>
+
+ </fileSets>
+
+</component>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-samples.xml b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-samples.xml
new file mode 100644
index 0000000000..740b7001ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/components/bin-samples.xml
@@ -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.
+-->
+<component>
+ <fileSets>
+ <!-- Add top level samples files -->
+ <fileSet>
+ <directory>../../samples</directory>
+ <outputDirectory>samples</outputDirectory>
+ <includes>
+ <include>README</include>
+ <include>logging.properties</include>
+ <include>build-common.xml</include>
+ <include>binding-ws-calculator/**/*</include>
+ <include>calculator/**/*</include>
+ <include>calculator-equinox/**/*</include>
+ <include>calculator-osgi/**/*</include>
+ <include>calculator-rmi-reference/**/*</include>
+ <include>calculator-rmi-service/**/*</include>
+ <include>implementation-java-calculator/**/*</include>
+ <include>dosgi-calculator/**/*</include>
+ <include>dosgi-calculator-operations/**/*</include>
+ <include>webapps/helloworld/**/*</include>
+ <include>webapps/helloworld-bpel/**/*</include>
+ <include>webapps/helloworld-jms/**/*</include>
+ <include>webapps/helloworld-js-client/**/*</include>
+ <include>webapps/helloworld-jsf/**/*</include>
+ <include>webapps/helloworld-jsp/**/*</include>
+ <include>webapps/helloworld-servlet/**/*</include>
+ <include>webapps/helloworld-stripes/**/*</include>
+ </includes>
+ <excludes>
+ <!-- General file/folders to exclude -->
+ <exclude>**/.*</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>**/*.log</exclude>
+ <exclude>**/*.svg</exclude>
+ <exclude>**/maven-eclipse.xml</exclude>
+
+ <!-- Sample specific files/folders to exclude -->
+ <exclude>pom.xml</exclude>
+ <!-- exclude>**/target</exclude -->
+ <!-- exclude>**/target/**/*</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/dependency-maven-plugin-markers/**/*</exclude>
+ <exclude>*/target/.felix</exclude>
+ <exclude>*/target/.felix/**/*</exclude>
+ <exclude>*/target/maven-archiver</exclude>
+ <exclude>*/target/maven-archiver/**/*</exclude>
+ <exclude>*/target/test-classes</exclude>
+ <exclude>*/target/test-classes/**/*</exclude>
+ <exclude>*/target/surefire-reports</exclude>
+ <exclude>*/target/surefire-reports/**/*</exclude>
+ <exclude>*/target/surefire-osgi-reports</exclude>
+ <exclude>*/target/surefire-osgi-reports/**/*</exclude>
+ <exclude>webapps/helloworld/target/**/*</exclude>
+ <exclude>webapps/helloworld-bpel/target/**/*</exclude>
+ <exclude>webapps/helloworld-jms/target/**/*</exclude>
+ <exclude>webapps/helloworld-js-client/target/**/*</exclude>
+ <exclude>webapps/helloworld-jsf/target/**/*</exclude>
+ <exclude>webapps/helloworld-jsp/target/**/*</exclude>
+ <exclude>webapps/helloworld-servlet/target/**/*</exclude>
+ <exclude>webapps/helloworld-stripes/target/**/*</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</component>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/INSTALL b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/INSTALL
new file mode 100644
index 0000000000..a1e3562d8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/INSTALL
@@ -0,0 +1,24 @@
+Installing the Apache Tuscany SCA 2.0-M4 November 2009 Release binary distribution
+==================================================================================
+
+Unzip Tuscany binary distribution archive and you get the following:
+
+tuscany-sca-2.0-M4
+ 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
+
+ /modules - all of the individual Tuscany jars and their dependencies
+
+ /samples - all the Tuscany samples, see the README in that directory
+
+
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/LICENSE b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/LICENSE
new file mode 100644
index 0000000000..f0190081ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/LICENSE
@@ -0,0 +1,1673 @@
+
+ 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-0.4.0-incubating.jar
+ abdera-core-0.4.0-incubating.jar
+ abdera-extensions-html-0.4.0-incubating.jar
+ abdera-extensions-json-0.4.0-incubating.jar
+ abdera-extensions-main-0.4.0-incubating.jar
+ abdera-i18n-0.4.0-incubating.jar
+ abdera-parser-0.4.0-incubating.jar
+ abdera-server-0.4.0-incubating.jar
+ addressing-1.3.mar
+ aopalliance-1.0.jar
+ annogen-0.1.0.jar
+ axiom-api-1.2.7.jar
+ axiom-dom-1.2.7.jar
+ axiom-impl-1.2.7.jar
+ axis2-codegen-1.4.1.jar
+ axis2-kernel-1.4.1.jar
+ axis2-java2wsdl-1.4.1.jar
+ axis2-mtompolicy-1.4.1.jar
+ axis-ant-1.4.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.0.1.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.2.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.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.0.1.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.2.1.jar
+ jackson-mapper-asl-1.2.1.jar
+ jettison-1.1.jar
+ jetty-6.1.19.jar
+ jetty-util-6.1.19.jar
+ juli-6.0.18.jar
+ log4j-1.2.15.jar
+ mex-1.41-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
+ spring-beans-2.5.5.jar
+ spring-context-2.5.5.jar
+ spring-core-2.5.5.jar
+ stripes-1.5.jar
+ tranql-connector-1.1.jar
+ tribes-6.0.18.jar
+ woden-api-1.0M8.jar
+ woden-impl-dom-1.0M8.jar
+ wss4j-1.5.4.jar
+ wstx-asl-3.2.4.jar
+ xalan-2.7.0.jar
+ xercesImpl-2.8.1.jar
+ xmlbeans-2.3.0.jar
+ xmlsec-1.4.2.jar
+ XmlSchema-1.4.2.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
+
+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,
+
+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.0.jar and slf4j-jdk14-1.5.0.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 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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/NOTICE b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/NOTICE
new file mode 100644
index 0000000000..cabd225df1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/bin/NOTICE
@@ -0,0 +1,85 @@
+Apache Tuscany
+Copyright (c) 2005 - 2009 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes/uses JSON-RPC-Java (http://oss.metaparadigm.com/jsonrpc/)
+
+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
+
+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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/README b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/README
new file mode 100644
index 0000000000..d651dfdeb7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/default.config b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/default.config
new file mode 100644
index 0000000000..d0f68de133
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/osgi.config b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/osgi.config
new file mode 100644
index 0000000000..9516b9db34
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.bat b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.bat
new file mode 100644
index 0000000000..cbf6962218
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.sh b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/tuscany.sh
new file mode 100644
index 0000000000..b053afe4e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/unmanaged.config b/tags/java/sca/2.0-M4-RC2/distribution/all/src/main/release/launcher/unmanaged.config
new file mode 100644
index 0000000000..ac99590ce9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/pom.xml
new file mode 100644
index 0000000000..9028e497b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/README.txt b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/README.txt
new file mode 100644
index 0000000000..b6158e3667
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/pom.xml
new file mode 100644
index 0000000000..960805ecbf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/download-tomcat/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/download-tomcat/pom.xml
new file mode 100644
index 0000000000..7de867b27b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/download-tomcat/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-distribution-tomcat-testing</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>download-tomcat</artifactId>
+ <packaging>pom</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>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>
+ <!-- Note: the url should be "archive.apache.org" but that is truncating the file at 4808k,
+ no idea why but it sounds like an infra problem - https://issues.apache.org/jira/browse/INFRA-1910 -->
+ <url>http://www.eu.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>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/pom.xml
new file mode 100644
index 0000000000..1e6de85863
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
+
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..8c67e05aa7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.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 testing;
+
+// TODO: should the webapp need to include the service interface?
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..c03a70c58a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..411d8a3146
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..d520375993
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/pom.xml
new file mode 100644
index 0000000000..74920f6823
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java
new file mode 100644
index 0000000000..c9c6ff66d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/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 testing;
+
+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("HelloworldImpl eager init: " + sayHello("world"));
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java
new file mode 100644
index 0000000000..65e95f275c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/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 testing;
+
+public interface HelloworldService {
+
+ String sayHello(String name);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..9bdfd4e58b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:testing="http://org.apache.tuscany.tomcat.testing">
+ <deployable composite="testing:helloworld-service-contribution"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..2d6ce9419b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://org.apache.tuscany.tomcat.testing"
+ name="helloworld-service-contribution">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="testing.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/pom.xml
new file mode 100644
index 0000000000..453e9063e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>war-legal-checks</artifactId>
+ <name>Apache Tuscany SCA WAR Distribution Legal Checks</name>
+
+ <dependencies>
+ </dependencies>
+
+ <build>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
new file mode 100644
index 0000000000..05f16f603d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.dir");
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/pom.xml
new file mode 100644
index 0000000000..47cf0ed2d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/testing/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-distribution-tomcat</artifactId>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-M4</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-client-webapp</module>
+ <module>legal-checks</module>
+ </modules>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/LICENSE b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..70e18a0c9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/NOTICE b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/NOTICE
new file mode 100644
index 0000000000..f5792022fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/NOTICE
@@ -0,0 +1,7 @@
+${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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/pom.xml
new file mode 100644
index 0000000000..a851e3e9ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java
new file mode 100644
index 0000000000..54947d6492
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java
new file mode 100644
index 0000000000..75f925fec5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.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.tomcat;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+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";
+
+ 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());
+ System.setProperty("org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint.enabled", "false");
+ File propFile = new File(webappDir, "tuscany.properties");
+ if (propFile.isFile()) {
+ try {
+ FileInputStream is = new FileInputStream(propFile);
+ Properties props = new Properties();
+ props.load(is);
+ is.close();
+ System.setProperty(TUSCANY_SHARED_PROP, props.getProperty("singleton", "false"));
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java
new file mode 100644
index 0000000000..5e9b5d90e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.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.tomcat;
+
+import java.io.File;
+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.Loader;
+import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.deploy.FilterDef;
+
+/**
+ * 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());
+
+ protected static final String TUSCANY_FILTER_NAME = "TuscanyFilter";
+ protected static final String TUSCANY_SERVLET_FILTER = "org.apache.tuscany.sca.host.webapp.TuscanyServletFilter";
+ protected static final String TUSCANY_CONTEXT_LISTENER = "org.apache.tuscany.sca.host.webapp.TuscanyContextListener";
+ protected static final String TUSCANY_MANAGER_LISTENER = "org.apache.tuscany.sca.tomcat.foo.TuscanyTomcatNode";
+
+ private boolean isSCAApp;
+
+ // TODO: this gives an instance per webapp, work out how to have only one per server
+ private static URLClassLoader tuscanyClassLoader;
+
+ /**
+ * 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() || isTuscanyManager()) {
+ String sharedProp = System.getProperty(TuscanyLifecycleListener.TUSCANY_SHARED_PROP, "false");
+ boolean shared = "true".equalsIgnoreCase(sharedProp);
+ if (!shared) {
+ setParentClassLoader(copy(getTuscanyClassloader(parent)));
+ } else {
+ // The default parent classloader is the one for the webapp
+ setParentClassLoader(getTuscanyClassloader(parent));
+ }
+ }
+
+ return super.getLoader();
+ }
+
+ @Override
+ public boolean listenerStart() {
+ if (isTuscanyManager()) {
+ // this isn't great having the manager app config scattered about different modules
+ // but is temp until this is all tidied up in a refactor after the basics are working
+ addApplicationListener(TUSCANY_MANAGER_LISTENER);
+ } else if (isSCAApp) {
+ enableTuscany();
+ }
+ return super.listenerStart();
+ }
+
+ private void enableTuscany() {
+
+ for (String listener : findApplicationListeners()) {
+ if (TUSCANY_CONTEXT_LISTENER.equals(listener)) {
+ // The web application already has the context listener configured
+ return;
+ }
+ }
+
+ for (FilterDef filterDef : findFilterDefs()) {
+ if (TUSCANY_SERVLET_FILTER.equals(filterDef.getFilterClass())) {
+ // The web application already has the filter configured
+ return;
+ }
+ }
+
+ addApplicationListener(TUSCANY_CONTEXT_LISTENER);
+
+ FilterDef filterDef = new FilterDef();
+ filterDef.setFilterName(TUSCANY_FILTER_NAME);
+ filterDef.setFilterClass(TUSCANY_SERVLET_FILTER);
+ addFilterDef(filterDef);
+
+ 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 boolean isTuscanyManager() {
+ return "/tuscany".equals(getName());
+ }
+
+ private static URLClassLoader copy(URLClassLoader classLoader) {
+ return new URLClassLoader(classLoader.getURLs(), classLoader.getParent());
+ }
+
+ private synchronized URLClassLoader getTuscanyClassloader(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);
+ return tuscanyClassLoader;
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return tuscanyClassLoader;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0b0e3e7d0d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/pom.xml
new file mode 100644
index 0000000000..06f8cd5e19
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java
new file mode 100644
index 0000000000..972aafd8b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.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.tomcat.foo;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+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.war.Installer;
+
+public class TuscanyTomcatNode implements ServletContextListener {
+
+ protected Node tomcatNode;
+
+ public void contextInitialized(ServletContextEvent arg0) {
+ if (!Installer.isTuscanyHookRunning()) {
+ return;
+ }
+
+ // TODO: this relys on the location of webapp folder, find way to get actual catalina base
+ File tomcatBase = new File(arg0.getServletContext().getRealPath("/")).getParentFile().getParentFile();
+
+ File contributionDir = new File(tomcatBase, "sca-contributions");
+ if (!contributionDir.exists()) {
+ return;
+ }
+ File[] contributionFiles = contributionDir.listFiles();
+ if (contributionFiles.length < 1) {
+ return;
+ }
+
+ Contribution[] nodeContributions = new Contribution[contributionFiles.length];
+ for (int i = 0; i<contributionFiles.length; i++) {
+ try {
+ nodeContributions[i] =
+ new Contribution(contributionFiles[i].getName(), contributionFiles[i].toURI().toURL().toString());
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ tomcatNode = NodeFactory.newInstance().createNode(nodeContributions);
+ tomcatNode.start();
+ }
+
+ public void contextDestroyed(ServletContextEvent arg0) {
+ if (tomcatNode != null) {
+ tomcatNode.stop();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
new file mode 100644
index 0000000000..2251a2e833
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java
@@ -0,0 +1,318 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 java.util.Properties;
+
+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(boolean singleton) {
+ try {
+
+ doInstall(singleton);
+ 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);
+ File propFile = new File(tuscanyWAR, "tuscany.properties");
+ if (propFile.isFile()) {
+ propFile.delete();
+ }
+
+ }
+
+ private boolean doInstall(boolean singleton) {
+ // 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()));
+
+ if (singleton) {
+ try {
+ // Write out a property file
+ File propFile = new File(tuscanyWAR, "tuscany.properties");
+ FileOutputStream os = new FileOutputStream(propFile);
+ Properties props = new Properties();
+ props.put("singleton", "true");
+ props.store(os, "Apache Tuscany properties for Tomcat");
+ os.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // Add Tuscany LifecycleListener to Tomcat server.xml
+ updateServerXml(serverXml);
+
+ return true;
+ }
+
+ 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;
+ }
+
+ 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);
+ }
+
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java
new file mode 100644
index 0000000000..a7e5c7e3d7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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"))) {
+ String singleton = req.getParameter("singleton");
+ installer.install(singleton!=null && singleton.equalsIgnoreCase("true"));
+ } 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/pom.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/pom.xml
new file mode 100644
index 0000000000..fc4744ffff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/pom.xml
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-tomcat-hook</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>war</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>src/main/assembly/war.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/assembly/war.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/assembly/war.xml
new file mode 100644
index 0000000000..2f1c6bc4d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/assembly/war.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT 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>
+ </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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE
new file mode 100644
index 0000000000..4e1a6a5bf0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE
@@ -0,0 +1,1117 @@
+
+ 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
+
+ activeio-core-3.1.0.jar
+ activemq-core-5.2.0.jar
+ addressing-1.3.mar
+ annogen-0.1.0.jar
+ axiom-api-1.2.7.jar
+ axiom-dom-1.2.7.jar
+ axiom-impl-1.2.7.jar
+ axis2-codegen-1.4.1.jar
+ axis2-kernel-1.4.1.jar
+ axis2-java2wsdl-1.4.1.jar
+ axis2-mtompolicy-1.4.1.jar
+ axis-ant-1.4.jar
+ camel-core-1.5.0.jar
+ cglib-2.2.jar
+ commons-collections-3.2.jar
+ commons-codec-1.3.jar,
+ commons-discovery-0.4.jar
+ commons-fileupload-1.2.jar
+ commons-httpclient-3.1.jar
+ commons-io-1.4.jar
+ commons-logging-1.1.1.jar
+ commons-logging-api-1.1.jar
+ geronimo-activation_1.1_spec-1.0.1.jar
+ geronimo-javamail_1.4_spec-1.2.jar
+ geronimo-j2ee-management_1.0_spec-1.0.jar
+ geronimo-jms_1.1_spec-1.1.1.jar
+ geronimo-stax-api_1.0_spec-1.0.1.jar
+ httpclient-4.0.jar,
+ httpcore-4.0.1.jar
+ httpcore-nio-4.0.1.jar
+ jackson-core-asl-1.2.1.jar
+ jackson-mapper-asl-1.2.1.jar
+ log4j-1.2.15.jar
+ mex-1.41-impl.jar
+ neethi-2.0.4.jar
+ opensaml-1.1.jar
+ rampart-core-1.4.jar
+ rampart-policy-1.4.jar
+ rampart-trust-1.4.jar
+ swizzle-stream-1.0.2.jar
+ woden-api-1.0M8.jar
+ woden-impl-dom-1.0M8.jar
+ wss4j-1.5.4.jar
+ wstx-asl-3.2.4.jar
+ xalan-2.7.0.jar
+ xercesImpl-2.8.1.jar
+ xmlsec-1.4.2.jar
+ XmlSchema-1.4.2.jar
+
+================================================================================
+
+xml-apis-1.0.b2.jar
+
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2001-2002 The Apache Software 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:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact apache@apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * 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 APACHE SOFTWARE FOUNDATION 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.
+
+================================================================================
+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 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,
+mail-1.4.jar,
+servlet-api-2.3.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/>.
+
+===============================================================================
+
+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 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 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE
new file mode 100644
index 0000000000..77d1c46d12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE
@@ -0,0 +1,79 @@
+Apache Tuscany
+Copyright (c) 2005 - 2009 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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..e6c3d23e9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp
new file mode 100644
index 0000000000..a6c3e4acaa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp
@@ -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.
+-->
+
+<%@ 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='checkbox' name='singleton' value='true'>The Tuscany runtime is shared by all web applications if checked.<p>
+ <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>
+
+ </body>
+</html>
diff --git a/tags/java/sca/2.0-M4-RC2/features/all/pom.xml b/tags/java/sca/2.0-M4-RC2/features/all/pom.xml
new file mode 100644
index 0000000000..7f70163362
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/all/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-feature</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-web20</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webapp</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-process</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-launcher</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-endpoint-tribes</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/api/pom.xml b/tags/java/sca/2.0-M4-RC2/features/api/pom.xml
new file mode 100644
index 0000000000..dbfc74b318
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <!-- Data Collection API -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Node API -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/core/pom.xml b/tags/java/sca/2.0-M4-RC2/features/core/pom.xml
new file mode 100644
index 0000000000..8a9256d7b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/core/pom.xml
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+
+ <!-- SCA API -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+-->
+
+ <!-- Assembly model -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-corba-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency-->
+
+ <!-- Contribution model -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Core runtime -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Data API -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency-->
+
+ <!-- Core Extensibility -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jse</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <!-- Implementation types -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Interface models -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Node runtime -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-webapp</artifactId>
+ <version>2.0-M4</version>
+ <type>war</type>
+ </dependency>
+ -->
+
+ <!-- Monitoring -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Policy models -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security-jsr250</artifactId>
+ <version>2.0-M4</version>
+ </dependency-->
+
+ <!-- XMLSchema support -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/ejava/pom.xml b/tags/java/sca/2.0-M4-RC2/features/ejava/pom.xml
new file mode 100644
index 0000000000..4dd43edce3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/ejava/pom.xml
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ejb-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+-->
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba-jee</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+-->
+
+ <!-- Implementations -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-ejb</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-sca</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- OSGi RFC 119 -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.osgi</groupId>
+ <artifactId>services</artifactId>
+ <version>3.2.0-v20090520-1800</version>
+ </dependency>
+
+
+ <!-- Policies -->
+<!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-transaction</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+-->
+ </dependencies>
+
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/pom.xml b/tags/java/sca/2.0-M4-RC2/features/pom.xml
new file mode 100644
index 0000000000..8969ebfea8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/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>
+ <relativePath>../pom.xml</relativePath>
+ <version>2.0-M4</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>process</module>
+ <module>webservice</module>
+ <module>web20</module>
+ <module>webapp</module>
+<!--
+ <module>manager</module>
+ <module>repository</module>
+-->
+ </modules>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/process/pom.xml b/tags/java/sca/2.0-M4-RC2/features/process/pom.xml
new file mode 100644
index 0000000000..d8c4e67c66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <!-- ODE BPEL -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/web20/pom.xml b/tags/java/sca/2.0-M4-RC2/features/web20/pom.xml
new file mode 100644
index 0000000000..90b89e7a7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/web20/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-feature</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+ <!-- Core distribution -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-atom-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonrpc-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!--Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/webapp/pom.xml b/tags/java/sca/2.0-M4-RC2/features/webapp/pom.xml
new file mode 100644
index 0000000000..3403b97cf3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-myfaces</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- JSONP Binding material -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <!-- end of JSONP Binding -->
+
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/features/webservice/pom.xml b/tags/java/sca/2.0-M4-RC2/features/webservice/pom.xml
new file mode 100644
index 0000000000..4d3094e83c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/features/webservice/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-feature</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <!-- Bindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-axis2-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <!-- Databindings -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <!--dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-sdo-axiom</artifactId>
+ <version>2.0-M4</version>
+ </dependency-->
+
+ <!-- Hosts -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/pom.xml
new file mode 100644
index 0000000000..44924206e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/pom.xml
@@ -0,0 +1,288 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld-reference</artifactId>
+ <name>Apache Tuscany SCA iTest HelloWorld Reference BPEL</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-M4</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>
+ <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>
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java
new file mode 100644
index 0000000000..d7dff093f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java
new file mode 100644
index 0000000000..5ecf5494be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java
new file mode 100644
index 0000000000..24ab0a4181
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..f46893481b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..a687534bb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..a9268ac1b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite
new file mode 100644
index 0000000000..faa10b90ca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl
new file mode 100644
index 0000000000..b976a53970
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..c0317687df
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..590f05ee84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..541a713112
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-reference/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..4e13380e0b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/pom.xml
new file mode 100644
index 0000000000..1403e2dd0e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/pom.xml
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one * or more
+ contributor license agreements. See the NOTICE file * distributed with
+ this work for additional information * regarding copyright ownership.
+ The ASF licenses this file * to you under the Apache License, Version
+ 2.0 (the * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at * *
+ http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by
+ applicable law or agreed to in writing, * software distributed under
+ the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES
+ OR CONDITIONS OF ANY * KIND, either express or implied. See the
+ License for 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld-ws
+ </artifactId>
+ <name>Apache Tuscany SCA iTest HelloWorld BPEL 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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</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>
+ <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>
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..0999e97065
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..315591fb98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..8cf91adc2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..f42325910d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld-ws/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..37f66e4189
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/pom.xml
new file mode 100644
index 0000000000..5e00bd0d5f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel-helloworld</artifactId>
+ <name>Apache Tuscany SCA iTest HelloWorld BPEL</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ </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>
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..0999e97065
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java
new file mode 100644
index 0000000000..86e6e4e9c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.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 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.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() 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..156e32e9ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite
new file mode 100644
index 0000000000..832c8f3702
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..c77318e8fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/itest/bpel/helloworld/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..37f66e4189
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/bpel/pom.xml
new file mode 100644
index 0000000000..bdd7788a37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bpel</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA BPEL Integration Tests</name>
+
+ <modules>
+ <module>helloworld</module>
+ <!--
+ <module>helloworld-reference</module>
+ <module>helloworld-ws</module>
+ -->
+ </modules>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/builder/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/pom.xml
new file mode 100644
index 0000000000..04d9fd64e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/builder/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-itest</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.8.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java
new file mode 100644
index 0000000000..b0dc7a6389
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java
new file mode 100644
index 0000000000..bf73a64027
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java
new file mode 100644
index 0000000000..6f36b1c55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java
new file mode 100644
index 0000000000..8c5c5de208
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java
new file mode 100644
index 0000000000..f4b8d2cf39
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java
new file mode 100644
index 0000000000..299f7606e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d8cb23bbd3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:ns1="http://scenario1">
+ <deployable composite="ns1:CompositeA" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1.composite
new file mode 100644
index 0000000000..4e58cdfa16
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario1/scenario1a.composite
new file mode 100644
index 0000000000..06b273c7a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ac01b3c687
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10.composite
new file mode 100644
index 0000000000..2d127a7bec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/scenario10a.composite
new file mode 100644
index 0000000000..98103e360e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/service3.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario10/service3.wsdl
new file mode 100644
index 0000000000..2477e23dc6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8b82b43c68
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11.composite
new file mode 100644
index 0000000000..2f5ca96d07
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/scenario11a.composite
new file mode 100644
index 0000000000..381ccddcc3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ <binding.ws />
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/service3.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario11/service3.wsdl
new file mode 100644
index 0000000000..2477e23dc6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..4028098023
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12.composite
new file mode 100644
index 0000000000..23799f8487
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario12/scenario12a.composite
new file mode 100644
index 0000000000..a2b4f88dc3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..1da59d5f04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13.composite
new file mode 100644
index 0000000000..631e38855f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario13/scenario13a.composite
new file mode 100644
index 0000000000..98976dc4e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b1d01afafb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:ns2="http://scenario2">
+ <deployable composite="ns2:CompositeA" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2.composite
new file mode 100644
index 0000000000..7672595959
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario2/scenario2a.composite
new file mode 100644
index 0000000000..2fe3592d12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..22950dfe03
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3.composite
new file mode 100644
index 0000000000..84f42c60fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario3/scenario3a.composite
new file mode 100644
index 0000000000..18ed91142c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a17e27c9d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4.composite
new file mode 100644
index 0000000000..a0bdb0197d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario4/scenario4a.composite
new file mode 100644
index 0000000000..1b4cf27c76
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..83a232db6e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5.composite
new file mode 100644
index 0000000000..2326afd2f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenario5a.composite
new file mode 100644
index 0000000000..fdf1423b66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenarios.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario5/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..776dfe4d97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://scenario6"
+ xmlns:ns6="http://scenario6">
+ <deployable composite="ns6:CompositeA" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6.composite
new file mode 100644
index 0000000000..9575612d51
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenario6a.composite
new file mode 100644
index 0000000000..9c7b58e2cb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenarios.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario6/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ede31d6bee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7.composite
new file mode 100644
index 0000000000..e1d2e0cefe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenario7a.composite
new file mode 100644
index 0000000000..ef16dc0785
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenarios.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario7/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7bb9e694a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8.composite
new file mode 100644
index 0000000000..467b7f57fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenario8a.composite
new file mode 100644
index 0000000000..9d9b5ba945
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenarios.wsdl b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario8/scenarios.wsdl
new file mode 100644
index 0000000000..5cda7327dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b6ec160506
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9.composite
new file mode 100644
index 0000000000..83584ed482
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9a.composite b/tags/java/sca/2.0-M4-RC2/itest/builder/src/main/resources/scenario9/scenario9a.composite
new file mode 100644
index 0000000000..0021ec242b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!-- bindings and/or interfaces may or may not be specified explicitly here -->
+ </reference>
+ <reference name="reference2a" promote="ComponentD/reference3a">
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java
new file mode 100644
index 0000000000..6d41581371
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.getWSDLDocument();
+ 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java
new file mode 100644
index 0000000000..27768f3799
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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).getExtensionPoints();
+
+ 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/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java b/tags/java/sca/2.0-M4-RC2/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java
new file mode 100644
index 0000000000..c5eb7a70ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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).getWSDLDocument());
+ }
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (Binding binding : componentReference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(component, componentReference, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ }
+
+ // 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).getWSDLDocument());
+ }
+ }
+ }
+ for (Reference reference : composite.getReferences()) {
+ for (Binding binding : reference.getBindings()) {
+ if (binding instanceof WebServiceBinding) {
+ writeWSDL(null, reference, ((WebServiceBinding)binding).getWSDLDocument());
+ }
+ }
+ }
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/itest/callback-api/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-api/pom.xml
new file mode 100644
index 0000000000..212bf0f572
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java
new file mode 100644
index 0000000000..b013462f9f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java
new file mode 100644
index 0000000000..252e4dc45f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java
new file mode 100644
index 0000000000..d883dc2d6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java
new file mode 100644
index 0000000000..afb7c45e2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java
new file mode 100644
index 0000000000..44f57b4316
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/CallBackApiTest.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/CallBackApiTest.composite
new file mode 100644
index 0000000000..309311e258
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..55736e5254
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackApiTest" />
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java
new file mode 100644
index 0000000000..75fab95efb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/pom.xml
new file mode 100644
index 0000000000..4be520aabd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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-itest</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-callback-basic-ws</artifactId>
+ <name>Apache Tuscany SCA iTest Callback Basic WebServices</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
new file mode 100644
index 0000000000..291a72b9d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java
new file mode 100644
index 0000000000..19f366c423
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
new file mode 100644
index 0000000000..4bb6b29a8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java
new file mode 100644
index 0000000000..5396879e83
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java
new file mode 100644
index 0000000000..07010f61e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite
new file mode 100644
index 0000000000..db1a2fbf6a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.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/200903"
+ targetNamespace="http://callback"
+ name="CallBackBasicTest">
+
+ <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>
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b58fabcd79
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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:t="http://callback">
+ <deployable composite="t:CallBackBasicTest" />
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
new file mode 100644
index 0000000000..43b812faed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-basic-ws/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/pom.xml
new file mode 100644
index 0000000000..f281878d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java
new file mode 100644
index 0000000000..291a72b9d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java
new file mode 100644
index 0000000000..19f366c423
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java
new file mode 100644
index 0000000000..4bb6b29a8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java
new file mode 100644
index 0000000000..5396879e83
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java
new file mode 100644
index 0000000000..07010f61e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/CallBackBasicTest.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/CallBackBasicTest.composite
new file mode 100644
index 0000000000..87cde940e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b58fabcd79
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://callback">
+ <deployable composite="t:CallBackBasicTest" />
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java
new file mode 100644
index 0000000000..43b812faed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/pom.xml
new file mode 100644
index 0000000000..2b22d38030
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java
new file mode 100644
index 0000000000..627d37e27d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java
new file mode 100644
index 0000000000..966ad17b9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java
new file mode 100644
index 0000000000..d2dc0add75
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java
new file mode 100644
index 0000000000..32ab1bdd3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java
new file mode 100644
index 0000000000..f7a1a195ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite
new file mode 100644
index 0000000000..2eea567fff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType
new file mode 100644
index 0000000000..af0b373472
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" >
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java
new file mode 100644
index 0000000000..dde489d766
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/pom.xml
new file mode 100644
index 0000000000..39a7f05332
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java
new file mode 100644
index 0000000000..49df5aa17a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.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.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.
+ */
+@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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite
new file mode 100644
index 0000000000..3d0b37eeae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/pom.xml
new file mode 100644
index 0000000000..823ef6dd18
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java
new file mode 100644
index 0000000000..dc66003604
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java
new file mode 100644
index 0000000000..f03144db8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java
new file mode 100644
index 0000000000..137ea6a658
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java
new file mode 100644
index 0000000000..4bf05fc925
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java
new file mode 100644
index 0000000000..bec98a49c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite
new file mode 100644
index 0000000000..f803fb2ec9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java
new file mode 100644
index 0000000000..c216cab1be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/component-type/pom.xml
new file mode 100644
index 0000000000..5e9d63778d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
+
diff --git a/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..8b6fe066a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..6f978bd9be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..1209ac128a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f7ac0b7287
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..b7dca792b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..77b128ab8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..ecee33e072
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType
new file mode 100644
index 0000000000..78e169deb4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <service name="AddService">
+ <interface.java interface="calculator.AddService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType
new file mode 100644
index 0000000000..5d66becedf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType
new file mode 100644
index 0000000000..22236ae0d0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <service name="DivideService">
+ <interface.java interface="calculator.DivideService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType
new file mode 100644
index 0000000000..2035d617e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <service name="MultiplyService">
+ <interface.java interface="calculator.MultiplyService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType
new file mode 100644
index 0000000000..fe76f553be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <service name="SubtractService">
+ <interface.java interface="calculator.SubtractService"/>
+ </service>
+
+</componentType>
+ \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/component-type/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/component-type/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..ac3ccc3d08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/pom.xml
new file mode 100644
index 0000000000..20ec8c6ae8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..b4c677b371
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java
new file mode 100644
index 0000000000..ef2a43c766
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite
new file mode 100644
index 0000000000..f67b212d99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..27a1ee74e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar
new file mode 100644
index 0000000000..fe264693fe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar
new file mode 100644
index 0000000000..d5dfb647d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository3/contribution.zip b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository3/contribution.zip
new file mode 100644
index 0000000000..b293aa4bcc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/contribution-folder/src/test/resources/repository3/contribution.zip
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/pom.xml
new file mode 100644
index 0000000000..1ab420e93c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java
new file mode 100644
index 0000000000..669821261c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java
new file mode 100644
index 0000000000..ff9f6e75f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..bea6f39932
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/hello.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/main/resources/hello.composite
new file mode 100644
index 0000000000..aeeab337fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/pom.xml
new file mode 100644
index 0000000000..cca05b9bb9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..7e11adcec7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..5a14b41650
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/pom.xml
new file mode 100644
index 0000000000..d8133c4acc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f11eacb416
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html
new file mode 100644
index 0000000000..1ff281373a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/pom.xml
new file mode 100644
index 0000000000..7c504aee50
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8254b667f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..0172fb2c7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd
new file mode 100644
index 0000000000..d49e2ead99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/pom.xml
new file mode 100644
index 0000000000..40dab26baa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..c062afaed0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java
new file mode 100644
index 0000000000..e03ed4dc25
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..130aa91093
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..0172fb2c7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd
new file mode 100644
index 0000000000..d49e2ead99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..44ceba1240
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/pom.xml
new file mode 100644
index 0000000000..91eb35d6c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0de3c70303
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..224e2c4d79
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..a53117e72f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/pom.xml
new file mode 100644
index 0000000000..0696df1951
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..ac6d7becb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/store.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/main/resources/store.composite
new file mode 100644
index 0000000000..bb5a7b764f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/pom.xml
new file mode 100644
index 0000000000..3d8b5e85c3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..0de3c70303
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java
new file mode 100644
index 0000000000..e03ed4dc25
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..268d90e910
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a47b9a71e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite
new file mode 100644
index 0000000000..76ccf71fb8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-import-export/pom.xml
new file mode 100644
index 0000000000..e64ff002e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/pom.xml
new file mode 100644
index 0000000000..51ee2a349d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..b4c677b371
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java
new file mode 100644
index 0000000000..303e2a6d9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/resources/repository/contribution.zip b/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/resources/repository/contribution.zip
new file mode 100644
index 0000000000..3239ae1242
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/contribution-zip/src/test/resources/repository/contribution.zip
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/build.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/build.xml
new file mode 100644
index 0000000000..68e15d4a8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/build.xml
@@ -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.
+-->
+<project name="itest-unzip" default="unzip">
+ <target name="unzip">
+ <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/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/pom.xml
new file mode 100644
index 0000000000..e87bf00476
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/bin-distro-unzip/pom.xml
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for 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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <name>Apache Tuscany SCA iTest Bin Distro Unzip</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-distribution-all</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</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>
+ <version>1.3</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>ant</groupId>
+ <artifactId>ant-trax</artifactId>
+ <version>1.6.5</version>
+ </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>
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/build.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/build.xml
new file mode 100644
index 0000000000..ed22bce2dc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/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-calculator"/>
+
+ </target>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/pom.xml
new file mode 100644
index 0000000000..681e1ed85c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/binding-ws-calculator/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-binding-ws-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution binding-ws-calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+ <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" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/build.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/build.xml
new file mode 100644
index 0000000000..25abf4e040
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/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="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">
+
+ <parallel>
+
+ <daemons>
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/calculator-rmi-service"/>
+ </daemons>
+
+ <sequential>
+ <sleep seconds="15"/>
+ <ant antfile="build.xml"
+ dir="${distro.root}/samples/calculator-rmi-reference"/>
+ </sequential>
+
+ </parallel>
+
+ </target>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/pom.xml
new file mode 100644
index 0000000000..7b39859144
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/calculator-rmi/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-calculator-rmi</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution calculator-rmi</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+ <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}" />
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/build.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/build.xml
new file mode 100644
index 0000000000..106fee758c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/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-calculator"/>
+
+ </target>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/pom.xml
new file mode 100644
index 0000000000..76f9c786b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/implementation-java-calculator/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-implementation-java-calculator</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution implementation-java-calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/pom.xml
new file mode 100644
index 0000000000..5aa8a2a44a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-legal-checks</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Legal Checks</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java
new file mode 100644
index 0000000000..2cbbe57125
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-")) {
+ // 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/tags/java/sca/2.0-M4-RC2/itest/distribution/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/pom.xml
new file mode 100644
index 0000000000..b62849a2ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <packaging>pom</packaging>
+ <artifactId>itest-distribution</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution</name>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ </build>
+
+ <modules>
+ <module>bin-distro-unzip</module>
+ <module>binding-ws-calculator</module>
+ <module>calculator-rmi</module>
+ <module>implementation-java-calculator</module>
+ <module>legal-checks</module>
+ <module>webapp-helloworld</module>
+ <module>webapp-helloworld-bpel</module>
+ <module>webapp-helloworld-js-client</module>
+ <module>webapp-helloworld-jsp</module>
+ <module>webapp-helloworld-stripes</module>
+ </modules>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/pom.xml
new file mode 100644
index 0000000000..da7b3f620d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-bpel</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-bpel</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-bpel</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>jetty6x</containerId>
+ <type>embedded</type>
+ <systemProperties>
+ <org.apache.commons.logging.Log>org.apache.commons.logging.impl.SimpleLog</org.apache.commons.logging.Log>
+ </systemProperties>
+ </container>
+ <!-- container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container -->
+ <configuration>
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!-- NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-bpel</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-bpel</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-bpel</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..5b29292acf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.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 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.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-bpel");
+ Iterator<?> ss = page.getAllHtmlChildElements();
+ ss.next();
+ ss.next();
+ ss.next();
+ HtmlParagraph p = (HtmlParagraph)ss.next();
+ assertEquals("Hello world", p.asText());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/pom.xml
new file mode 100644
index 0000000000..3d79100bb0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/pom.xml
@@ -0,0 +1,216 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for 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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-jms</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-jms</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jms</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ <version>6.1.19</version>
+ <type>pom</type>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-naming</artifactId>
+ <version>6.1.19</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ <version>6.1.19</version>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jta</artifactId>
+ <version>1.0.1B-rc4</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <!--
+ you can call the containerid anything that doesn't start with 'jetty' (Jetty will work fine)
+ if it starts with 'jetty' it will use the automatic dependency mechanism which you don't
+ want
+ <containerId>latest-jetty6x</containerId>
+ -->
+ <containerId>jetty6x</containerId>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer
+ </implementation>
+ <type>embedded</type>
+ <dependencies>
+ <!-- add all the other dependencies that the embedded jetty server needs here -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-plus</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-naming</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>geronimo-spec</groupId>
+ <artifactId>geronimo-spec-jta</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler-jdt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-api-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-el</groupId>
+ <artifactId>commons-el</artifactId>
+ </dependency>
+
+ </dependencies>
+ </container>
+ <!-- Uncomment the following to enable Tomcat container -->
+ <!--
+ <container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container>
+ -->
+ <configuration>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration
+ </implementation>
+
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!--
+ NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation
+ -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-jms</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jms</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-jms</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..bc436667c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jms/src/test/java/itest/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 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.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-jms");
+ Iterator<?> ss = page.getAllHtmlChildElements();
+ ss.next();
+ ss.next();
+ ss.next();
+ ss.next();
+ HtmlParagraph p = (HtmlParagraph)ss.next();
+ assertEquals("Hello world", p.asText());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/pom.xml
new file mode 100644
index 0000000000..bca540e6dc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-js-client</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-js-client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-js-client</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ <version>6.1.19</version>
+ <type>pom</type>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <!--
+ you can call the containerid anything that doesn't start with 'jetty' (Jetty will work fine)
+ if it starts with 'jetty' it will use the automatic dependency mechanism which you don't
+ want
+ -->
+ <containerId>latest-jetty6x</containerId>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer
+ </implementation>
+ <type>embedded</type>
+ <dependencies>
+ <!-- add all the other dependencies that the embedded jetty server needs here -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler-jdt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-api-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-el</groupId>
+ <artifactId>commons-el</artifactId>
+ </dependency>
+
+ </dependencies>
+ </container>
+ <!-- Uncomment the following to enable Tomcat container -->
+ <!--
+ <container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container>
+ -->
+ <configuration>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration
+ </implementation>
+
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!--
+ NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation
+ -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-jsp</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-js-client</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-js-client</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..099b442050
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-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/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/pom.xml
new file mode 100644
index 0000000000..4b4f07f2e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-jsf</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-jsf</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jsf</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>jetty6x</containerId>
+ <type>embedded</type>
+ <systemProperties>
+ <org.apache.commons.logging.Log>org.apache.commons.logging.impl.SimpleLog</org.apache.commons.logging.Log>
+ </systemProperties>
+ </container>
+ <!-- container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container -->
+ <configuration>
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!-- NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-jsf</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jsf</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-jsf</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java
new file mode 100644
index 0000000000..1f90a772ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.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 itest;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Iterator;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlForm;
+import com.gargoylesoftware.htmlunit.html.HtmlInput;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlParagraph;
+
+/**
+ * TODO: This doesn't work yet, I can't find the hello response in the
+ * the response page from the button click. Not sure if thats just
+ * looking in the wrong place or the button click is not working
+ * Also the Cargo maven plugin has a problem finding the el-api when using Jetty
+ */
+public class HelloworldTestCaseFIXME {
+
+ @Test
+ public void testA() throws FailingHttpStatusCodeException, MalformedURLException, IOException {
+ HtmlPage page = (HtmlPage)new WebClient().getPage("http://localhost:8085/helloworld-jsf");
+
+ HtmlForm form = page.getFormByName("mainForm");
+
+ HtmlInput textField = form.getInputByName("mainForm:name");
+ textField.setValueAttribute("root");
+
+ Iterator i = form.getChildIterator();
+ i.next();
+ HtmlInput button = (HtmlInput)i.next();
+
+ HtmlPage page2 = (HtmlPage)button.click();
+
+ Iterator<?> ss = page2.getAllHtmlChildElements();
+ ss.next();
+ ss.next();
+ ss.next();
+ ss.next();
+ HtmlForm form2 = (HtmlForm)ss.next();
+
+ Object oow = form2.getFirstChild();
+ System.out.println(oow);
+// assertTrue(p.asText().startsWith("Hello Petra"));
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/pom.xml
new file mode 100644
index 0000000000..584f2f1038
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-jsp</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-jsp</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jsp</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ <version>6.1.19</version>
+ <type>pom</type>
+ <scope>compile</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <!--
+ you can call the containerid anything that doesn't start with 'jetty' (Jetty will work fine)
+ if it starts with 'jetty' it will use the automatic dependency mechanism which you don't
+ want
+ -->
+ <containerId>latest-jetty6x</containerId>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer
+ </implementation>
+ <type>embedded</type>
+ <dependencies>
+ <!-- add all the other dependencies that the embedded jetty server needs here -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-runtime</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>tomcat</groupId>
+ <artifactId>jasper-compiler-jdt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jsp-api-2.0</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-el</groupId>
+ <artifactId>commons-el</artifactId>
+ </dependency>
+
+ </dependencies>
+ </container>
+ <!-- Uncomment the following to enable Tomcat container -->
+ <!--
+ <container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container>
+ -->
+ <configuration>
+ <implementation>org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration
+ </implementation>
+
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!--
+ NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation
+ -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-jsp</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-jsp</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-jsp</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..2be60be081
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.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 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.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();
+ ss.next();
+ ss.next();
+ ss.next();
+ HtmlParagraph p = (HtmlParagraph)ss.next();
+ assertEquals("Hello world", p.asText());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/pom.xml
new file mode 100644
index 0000000000..6cb817579f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld-stripes</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld-stripes</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-stripes</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>htmlunit</groupId>
+ <artifactId>htmlunit</artifactId>
+ <version>1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>compile</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>jetty6x</containerId>
+ <type>embedded</type>
+ <systemProperties>
+ <org.apache.commons.logging.Log>org.apache.commons.logging.impl.SimpleLog</org.apache.commons.logging.Log>
+ </systemProperties>
+ </container>
+ <!-- container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container -->
+ <configuration>
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!-- NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ <context>helloworld-stripes</context>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld-stripes</artifactId>
+ <type>war</type>
+ <properties>
+ <context>helloworld-stripes</context>
+ </properties>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java
new file mode 100644
index 0000000000..743ab054c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-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.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();
+ Object o1= ss.next();
+ Object o2= ss.next();
+ Object o3= ss.next();
+ Object o4= ss.next();
+ Object o5= ss.next();
+ Object o6= ss.next();
+ HtmlParagraph p = (HtmlParagraph)ss.next();
+ assertEquals("sayHello returns: Hello world", p.asText());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld/pom.xml
new file mode 100644
index 0000000000..2eea7bfcd6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/distribution/webapp-helloworld/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>itest-distribution</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>itest-distribution-webapp-helloworld</artifactId>
+ <name>Apache Tuscany SCA iTest Distribution Webapp helloworld</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-bin-distro-unzip</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld</artifactId>
+ <type>war</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>httpunit</groupId>
+ <artifactId>httpunit</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.cargo</groupId>
+ <artifactId>cargo-maven2-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <id>start-container</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <goals>
+ <goal>stop</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <wait>false</wait>
+ <container>
+ <containerId>jetty6x</containerId>
+ <type>embedded</type>
+ <systemProperties>
+ <org.apache.commons.logging.Log>org.apache.commons.logging.impl.SimpleLog</org.apache.commons.logging.Log>
+ </systemProperties>
+ </container>
+ <!-- container>
+ <containerId>tomcat6x</containerId>
+ <home>/Tomcat/apache-tomcat-6.0.18</home>
+ </container -->
+ <configuration>
+ <home>${project.build.directory}/cargo-jetty</home>
+ <properties>
+ <!-- NOTE: remote debugging doesn't work with the embedded Jetty container. To remote debug
+ uncomment/comment the container above to be the Tomcat container and set home to point
+ to your local Tomcat installation -->
+ <cargo.jvmargs><![CDATA[-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y]]></cargo.jvmargs>
+ <cargo.servlet.port>8085</cargo.servlet.port>
+ </properties>
+ <deployables>
+ <deployable>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>helloworld</artifactId>
+ <type>war</type>
+ <pingURL>http://localhost:8085/helloworld</pingURL>
+ </deployable>
+ </deployables>
+ </configuration>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/endpoints/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/endpoints/pom.xml
new file mode 100644
index 0000000000..f91d34f151
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..c307547f56
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..064d615c45
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/EndpointsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/EndpointsTestCase.java
new file mode 100644
index 0000000000..7802848c3b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java
new file mode 100644
index 0000000000..f3b6c15bf1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/Utils.java b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/java/test/Utils.java
new file mode 100644
index 0000000000..5107d8f660
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/helloworld.composite
new file mode 100644
index 0000000000..081804b34e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/nested.composite b/tags/java/sca/2.0-M4-RC2/itest/endpoints/src/test/resources/nested.composite
new file mode 100644
index 0000000000..ffc73644f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/exceptions/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/exceptions/pom.xml
new file mode 100644
index 0000000000..48a8bea40f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java
new file mode 100644
index 0000000000..1f57116bac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java
new file mode 100644
index 0000000000..112aefc747
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java
new file mode 100644
index 0000000000..53a6c70b57
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java
new file mode 100644
index 0000000000..ace219991b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java
new file mode 100644
index 0000000000..453528444d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java
new file mode 100644
index 0000000000..26b9f0a383
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java
new file mode 100644
index 0000000000..cd62338841
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java
new file mode 100644
index 0000000000..56b9fc6f5b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java
new file mode 100644
index 0000000000..c5b54ff902
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/resources/ExceptionTest.composite b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/main/resources/ExceptionTest.composite
new file mode 100644
index 0000000000..d42866303e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java
new file mode 100644
index 0000000000..7794348476
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/pom.xml
new file mode 100644
index 0000000000..623cef9b09
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-itest</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-spring-sca</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java
new file mode 100644
index 0000000000..bd7770ca7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java
new file mode 100644
index 0000000000..747433a9e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..eae607a7ca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..ce1cdaae5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..b033516c1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java
new file mode 100644
index 0000000000..4f063993a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java
new file mode 100644
index 0000000000..b3ef6e7312
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java
new file mode 100644
index 0000000000..595626e672
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java
new file mode 100644
index 0000000000..fed509df98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java
new file mode 100644
index 0000000000..8bb3006d12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..f68134702b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java
new file mode 100644
index 0000000000..78b3649b5b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBean.java
new file mode 100644
index 0000000000..1a0abd7f8f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java
new file mode 100644
index 0000000000..e3d9a36bb8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java
new file mode 100644
index 0000000000..47342fded8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReference.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReference.java
new file mode 100644
index 0000000000..6f5b280f31
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java
new file mode 100644
index 0000000000..dea7933e1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java
new file mode 100644
index 0000000000..b80b05dc08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..ecb085858d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.Destroy;
+import org.oasisopen.sca.annotation.Init;
+import org.oasisopen.sca.annotation.Service;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Property;
+import org.oasisopen.sca.annotation.ComponentName;
+
+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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml
new file mode 100644
index 0000000000..81d59432b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite
new file mode 100644
index 0000000000..abdaa98bff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite
new file mode 100644
index 0000000000..dd186bddfc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml
new file mode 100644
index 0000000000..c50f0ef4d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml
new file mode 100644
index 0000000000..a0bb10e8dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite
new file mode 100644
index 0000000000..1c4b81db33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://stockquote"
+ xmlns:hw="http://stockquote"
+ name="MultipleContext">
+
+ <component name="StockQuoteServiceComponent">
+ <implementation.spring location="springapp"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9267f28e83
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml
new file mode 100644
index 0000000000..dcc88f6770
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config
new file mode 100644
index 0000000000..0e7cb86633
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config
@@ -0,0 +1,3 @@
+Calculator {
+ calculator.security.JaasLoginModule required debug=true;
+};
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties
new file mode 100644
index 0000000000..0238f0b013
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite
new file mode 100644
index 0000000000..1000e616a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <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" requires="tuscany:jaasAuthentication"/>
+ <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" requires="tuscany:jaasAuthentication"/>
+ </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" requires="tuscany:jaasAuthentication"/>
+ <reference name="divideService" target="DivideServiceComponent" />
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml
new file mode 100644
index 0000000000..c50f0ef4d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml
new file mode 100644
index 0000000000..278c94a18e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml
@@ -0,0 +1,40 @@
+<?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/200903" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:calc="http://calculator">
+
+ <!-- PolicySets -->
+ <policySet name="JaasPolicy" provides="tuscany:jaasAuthentication" appliesTo="sca:implementation.java"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <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"
+ xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <tuscany:jdkLogger name="calculator">
+ <logLevel>FINER</logLevel>
+ </tuscany:jdkLogger>
+ </policySet>
+</definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite
new file mode 100644
index 0000000000..2731fc455f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..950dbeba4c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite
new file mode 100644
index 0000000000..e8357cc62e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar
new file mode 100644
index 0000000000..504d59e5ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite
new file mode 100644
index 0000000000..b8389be7f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite
new file mode 100644
index 0000000000..8d1a655c4e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml
new file mode 100644
index 0000000000..1705164104
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml
new file mode 100644
index 0000000000..539dfa6e32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite
new file mode 100644
index 0000000000..294b211431
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite
new file mode 100644
index 0000000000..c77ab00323
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml
new file mode 100644
index 0000000000..42e0cdbd23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-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 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"
+ 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"/>
+
+ <bean id="testBean"
+ class="mock.TestHelloWorldBean"
+ lazy-init="true">
+ </bean>
+
+</beans> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml
new file mode 100644
index 0000000000..83558e8abc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite
new file mode 100644
index 0000000000..b7c45b289f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite
new file mode 100644
index 0000000000..e1ccbcf3c6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite
new file mode 100644
index 0000000000..236e2b23e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml
new file mode 100644
index 0000000000..4a873f2424
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java
new file mode 100644
index 0000000000..4503294f10
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/CalculatorClient.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 context.access;
+
+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;
+import org.springframework.context.ApplicationContext;
+
+import context.access.SCAApplicationContextProvider;
+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 =
+ ((Client)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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java
new file mode 100644
index 0000000000..2602839d1d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java
new file mode 100644
index 0000000000..254b8100e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.Contribution;
+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 =
+ ((Client)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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java
new file mode 100644
index 0000000000..8df60c5bab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java
new file mode 100644
index 0000000000..f5261c85bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java
new file mode 100644
index 0000000000..9ff1b74567
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.ContributionLocationHelper;
+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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java
new file mode 100644
index 0000000000..8b12dd7af7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.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 implementation.policies;
+
+import java.io.File;
+
+import javax.security.auth.login.Configuration;
+import org.apache.tuscany.sca.node.Client;
+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 =
+ ((Client)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 =
+ ((Client)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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java
new file mode 100644
index 0000000000..a44ae38d24
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java
new file mode 100644
index 0000000000..d54f0544d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java
new file mode 100644
index 0000000000..71768f5a7b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java
new file mode 100644
index 0000000000..0c6f8d2e84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java
new file mode 100644
index 0000000000..73b151bf7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.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.itest.spring;
+
+import java.io.File;
+import junit.framework.TestCase;
+import java.net.MalformedURLException;
+
+import org.apache.tuscany.sca.node.Client;
+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 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 = ((Client)node).getService(getServiceClass(), "ClientComponent");
+ }
+
+ abstract protected Class<T> getServiceClass();
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java
new file mode 100644
index 0000000000..5869d344f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java
new file mode 100644
index 0000000000..90d26dd89f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java
new file mode 100644
index 0000000000..f28dace31a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java
new file mode 100644
index 0000000000..def30b3ea0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java
new file mode 100644
index 0000000000..fa7967c964
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java
new file mode 100644
index 0000000000..b57cc7f366
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java
new file mode 100644
index 0000000000..0c2e1daa81
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java
new file mode 100644
index 0000000000..8d0c548899
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java
new file mode 100644
index 0000000000..f4bd53876c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java
new file mode 100644
index 0000000000..0907985d7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java
new file mode 100644
index 0000000000..13b84c8c73
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.Client;
+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 =
+ ((Client)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/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java
new file mode 100644
index 0000000000..5db9c84c00
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/interfaces/pom.xml
new file mode 100644
index 0000000000..d55c008338
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java
new file mode 100644
index 0000000000..f4131593d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java
new file mode 100644
index 0000000000..5fc9ed51b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 foo1(String str) throws Exception;
+
+ String foo2(String str, int i);
+
+ String foo2(int i, String str) throws Exception;
+
+ void callback(String str);
+
+ void callModifyParameter();
+
+ @OneWay
+ void onewayMethod(String str);
+
+ String getCallbackValue();
+
+ String getOnewayValue();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java
new file mode 100644
index 0000000000..6cd937af12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 foo1(String str) throws Exception {
+ return str + "AComponent";
+ }
+
+ public String foo2(String str, int i) {
+ return str + "AComponent" + i;
+ }
+
+ public String foo2(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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java
new file mode 100644
index 0000000000..05a9d09bdd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java
new file mode 100644
index 0000000000..ab0b18191c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java
new file mode 100644
index 0000000000..724d94dffb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java
new file mode 100644
index 0000000000..be3fa4c15a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java
new file mode 100644
index 0000000000..9f34dfd274
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
new file mode 100644
index 0000000000..541b1f1508
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java
new file mode 100644
index 0000000000..b29b298ab6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java
new file mode 100644
index 0000000000..00a0f5645b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InterfacesTest.composite b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InterfacesTest.composite
new file mode 100644
index 0000000000..27ada047b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite
new file mode 100644
index 0000000000..c91d49a49a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/main/resources/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
new file mode 100644
index 0000000000..31e40d59c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.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.itest.interfaces;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+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;
+
+@Ignore("TUSCANY-3138")
+public class InterfacesTestCase {
+ private static Node node;
+
+ @BeforeClass
+ public static void init() throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation("InterfacesTest.composite");
+ 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.foo1("A"));
+
+ assertEquals("AAComponent1", local.foo2("A", 1));
+ assertEquals("AAComponent1", local.foo2(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"));
+
+ // 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/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java
new file mode 100644
index 0000000000..b1d4dba07d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.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.apache.tuscany.sca.interfacedef.InvalidAnnotationException;
+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;
+
+public class InvalidRemoteAttributeTestCase {
+
+ @Test
+ public void testInvalidRemoteAttribute() throws Exception {
+ Node node = null;
+
+ try {
+ String location = ContributionLocationHelper.getContributionLocation("InvalidRemoteAttribute.composite");
+ 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/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/pom.xml
new file mode 100644
index 0000000000..b149bbaf6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java
new file mode 100644
index 0000000000..4e55bae98d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java
new file mode 100644
index 0000000000..0bf3328c31
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java
new file mode 100644
index 0000000000..a43b85361b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java
new file mode 100644
index 0000000000..b15ab6be08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..11ace7a788
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest/jaxws">
+ <deployable composite="itest:jaxwsAsync"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite
new file mode 100644
index 0000000000..313edf0435
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java
new file mode 100644
index 0000000000..eb72924093
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jaxws/pom.xml
new file mode 100644
index 0000000000..751935be6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jaxws</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java
new file mode 100644
index 0000000000..e1c2bedea3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuote.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuote.java
new file mode 100644
index 0000000000..74e25bb3bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuoteImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/java/stock/StockQuoteImpl.java
new file mode 100644
index 0000000000..516c63d864
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/resources/StockQuote.composite b/tags/java/sca/2.0-M4-RC2/itest/jaxws/src/test/resources/StockQuote.composite
new file mode 100644
index 0000000000..b2c9bd8ddb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/pom.xml
new file mode 100644
index 0000000000..e1ab18de9b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a9d43b5637
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:DynamicComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite
new file mode 100644
index 0000000000..cbad991ac5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..01553a968c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java
new file mode 100644
index 0000000000..3bf4e0bc30
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/args/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/args/pom.xml
new file mode 100644
index 0000000000..cb666cac7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..68506b857b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java
new file mode 100644
index 0000000000..5f19aa1fa5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java
new file mode 100644
index 0000000000..18324d5d1d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..07caa57490
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefinitionsTests"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..bb431a592b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/selectors/selectors.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/main/resources/selectors/selectors.composite
new file mode 100644
index 0000000000..1a9075f6d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java
new file mode 100644
index 0000000000..28e0b530c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/pom.xml
new file mode 100644
index 0000000000..9929f87db5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
new file mode 100644
index 0000000000..d4cd5df431
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java
new file mode 100644
index 0000000000..a4d5190af3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java
new file mode 100644
index 0000000000..b78feab413
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java
new file mode 100644
index 0000000000..20b74ccc1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java
new file mode 100644
index 0000000000..e8357338ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..95c3a41c43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:CallbackClientComposite"/>
+ <deployable composite="itest:CallbackTempQComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..dec266b133
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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.ServiceQueue = 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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/client.composite
new file mode 100644
index 0000000000..19124fc3e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:ServiceQueue"/>
+ <callback>
+ <binding.jms uri="jms:CallbackQueue"/>
+ </callback>
+ </reference>
+ </component>
+
+ <component name="ServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.JMSServiceImpl" />
+ <service name="JMSService">
+ <binding.jms uri="jms:ServiceQueue"/>
+ <callback>
+ <binding.jms uri="jms:CallbackQueue"/>
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/tempq.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/main/resources/simple/tempq.composite
new file mode 100644
index 0000000000..5ef7c981f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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:TQServiceQueue"/>
+ <callback>
+ <binding.jms />
+ </callback>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java
new file mode 100644
index 0000000000..18911ad8b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java
new file mode 100644
index 0000000000..b335add358
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/pom.xml
new file mode 100644
index 0000000000..8d78fde377
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..2a74e465ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefaultServiceComposite"/>
+ <deployable composite="itest:DefaultClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/client.composite
new file mode 100644
index 0000000000..c4d5215f86
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:HelloWorldService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/defaults/service.composite
new file mode 100644
index 0000000000..a4de896f24
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/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/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java
new file mode 100644
index 0000000000..d2b1a5fe59
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/pom.xml
new file mode 100644
index 0000000000..545ae23615
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..6b763874df
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..07caa57490
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:DefinitionsTests"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions.xml
new file mode 100644
index 0000000000..07b9f4aaa8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions/definitions.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/definitions/definitions.composite
new file mode 100644
index 0000000000..67a62a7165
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..f7555e0beb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java
new file mode 100644
index 0000000000..729ad072b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/pom.xml
new file mode 100644
index 0000000000..e4d8401cba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java
new file mode 100644
index 0000000000..469882f3b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java
new file mode 100644
index 0000000000..19b584950a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java
new file mode 100644
index 0000000000..b12e3a562e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java
new file mode 100644
index 0000000000..b23db73c01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
new file mode 100644
index 0000000000..9e4c4c46d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java
new file mode 100644
index 0000000000..866acf1ce1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c9945cc57d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExceptionServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/exceptions/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/exceptions/service.composite
new file mode 100644
index 0000000000..9eb8f2b27d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="ObjectExceptionService"/>
+ <tuscany:wireFormat.jmsObject/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..72d5457faf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
new file mode 100644
index 0000000000..1e1a0987ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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("java.lang.RuntimeException".equals(o.getClass().getName()));
+ assertEquals("java.lang.RuntimeException: 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("java.lang.RuntimeException".equals(o.getClass().getName()));
+ assertEquals("java.lang.RuntimeException: 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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/pom.xml
new file mode 100644
index 0000000000..a2a029c018
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java
new file mode 100644
index 0000000000..469882f3b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java
new file mode 100644
index 0000000000..19b584950a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java
new file mode 100644
index 0000000000..b12e3a562e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java
new file mode 100644
index 0000000000..b23db73c01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java
new file mode 100644
index 0000000000..9e4c4c46d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java
new file mode 100644
index 0000000000..02426936d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java
new file mode 100644
index 0000000000..866acf1ce1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c28c94da98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExceptionServiceComposite"/>
+ <deployable composite="itest:ExceptionClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/client.composite
new file mode 100644
index 0000000000..5d1c57a1f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:ExceptionService" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/exceptions/service.composite
new file mode 100644
index 0000000000..6875772d56
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/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/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java
new file mode 100644
index 0000000000..170e28b15d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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("java.lang.RuntimeException: bla", e.getCause().getMessage());
+ }
+ }
+
+ @After
+ public void end() {
+ if (node != null) {
+ node.stop();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/pom.xml
new file mode 100644
index 0000000000..a4625ca7f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..60b132ca1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ExternalServiceComposite"/>
+ <deployable composite="itest:ExternalClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/client.composite
new file mode 100644
index 0000000000..cad76ef45f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:61616">
+ <destination jndiName="DestQueueA"/>
+ <response>
+ <destination jndiName="RespQueueA"/>
+ </response>
+ </binding.jms>
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/external/service.composite
new file mode 100644
index 0000000000..8a76d8cd29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:61616">
+ <destination jndiName="DestQueueA" create="always"/>
+ <response>
+ <destination jndiName="RespQueueA" create="always"/>
+ </response>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java
new file mode 100644
index 0000000000..b8cbde7b26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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:61616");
+ broker.start();
+ }
+ protected void stopBroker() throws Exception {
+ if (broker != null) {
+ broker.stop();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/pom.xml
new file mode 100644
index 0000000000..81b31c6f6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite
new file mode 100644
index 0000000000..e5a904871c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsBytes/>
+ </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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsBytes/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/pom.xml
new file mode 100644
index 0000000000..6f9cdd01cf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite
new file mode 100644
index 0000000000..a28e6e5f6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsBytesXML/>
+ </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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsBytesXML/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/pom.xml
new file mode 100644
index 0000000000..7240897436
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite
new file mode 100644
index 0000000000..a6d6e04ac8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:wireFormat.jmsdefault/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService3" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService3"/>
+ <tuscany:wireFormat.jmsdefault/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService4" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService4"/>
+ <tuscany:wireFormat.jmsdefault sendFormat="text"/>
+ </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>
+ <destination jndiName="HelloWorldService3"/>
+ <tuscany:wireFormat.jmsdefault />
+ </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>
+ <destination jndiName="HelloWorldService4"/>
+ <tuscany:wireFormat.jmsdefault />
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl
new file mode 100644
index 0000000000..935a2e73c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/pom.xml
new file mode 100644
index 0000000000..b0d00e6082
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite
new file mode 100644
index 0000000000..c624a11233
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsText/>
+ </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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl
new file mode 100644
index 0000000000..f72ce434fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/pom.xml
new file mode 100644
index 0000000000..05c3e3e328
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite
new file mode 100644
index 0000000000..e037aa74d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.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://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsObject wrapSingle="true"/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldServiceDontWrapSingle" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:wireFormat.jmsObject wrapSingle="false" />
+ </binding.jms>
+ </reference>
+ </component>
+
+ <component name="HelloWorldServiceComponent1">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.format.jmsobject.helloworld.HelloWorldServiceImpl" />
+ <service name="HelloWorldService">
+ <interface.wsdl interface="http://helloworld.jmsobject.format.jms.binding.sca.tuscany.apache.org/#wsdl.interface(HelloWorldService)"/>
+ <binding.jms>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsObject wrapSingle="true"/>
+ </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>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:wireFormat.jmsObject /> <!-- test that wrapSingle default works -->
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl
new file mode 100644
index 0000000000..4625f46578
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl
@@ -0,0 +1,368 @@
+<?xml version="1.0" encoding="UTF-8"?>
+ <!--
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ or more contributor license agreements. See the NOTICE file *
+ distributed with this work for additional information *
+ regarding copyright ownership. The ASF licenses this file * to
+ you under the Apache License, Version 2.0 (the * "License"); you
+ may not use this file except in compliance * with the License.
+ You may obtain a copy of the License at * *
+ http://www.apache.org/licenses/LICENSE-2.0 * * Unless required
+ by applicable law or agreed to in writing, * software
+ distributed under the License is distributed on an * "AS IS"
+ BASIS, WITHOUT 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="HelloWorldServiceService"
+ targetNamespace="http://helloworld.jmsobject.format.jms.binding.sca.tuscany.apache.org/"
+ xmlns:tns="http://helloworld.jmsobject.format.jms.binding.sca.tuscany.apache.org/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/">
+ <wsdl:types>
+ <xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:complexType name="person">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="firstName"
+ type="xs:string" />
+ <xs:element minOccurs="0" name="lastName"
+ type="xs:string" />
+ </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: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:schema>
+ <xs:schema attributeFormDefault="qualified"
+ elementFormDefault="unqualified"
+ targetNamespace="http://helloworld.jmsobject.format.jms.binding.sca.tuscany.apache.org/"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:import />
+ <xs:import />
+ <xs:import />
+ <xs:import />
+ <xs:element name="getObjectGreetingResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNullReturnGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="person" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getPersonGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="person" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getPersonGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="person" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getMultiGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getObjectArrayGreeting">
+ <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="getArrayGreeting">
+ <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="getObjectArrayGreetingResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getMultiArrayGreetingsResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getObjectGreeting">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:anyType" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getNullReturnGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="person" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getMultiArrayGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded"
+ minOccurs="0" name="arg0" nillable="true"
+ type="xs:string" />
+ <xs:element maxOccurs="unbounded"
+ minOccurs="0" name="arg1" nillable="true"
+ type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getMultiGreetings">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="arg0"
+ nillable="true" type="xs:string" />
+ <xs:element minOccurs="0" name="arg1"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="getArrayGreetingResponse">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element minOccurs="0" name="return"
+ nillable="true" type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:element name="CheckedException" type="xs:string" />
+
+ </xs:schema>
+ </wsdl:types>
+ <wsdl:message name="getObjectGreetingResponse">
+ <wsdl:part name="getObjectGreetingResponse" element="tns:getObjectGreetingResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNullReturnGreetingsResponse">
+ <wsdl:part name="getNullReturnGreetingsResponse"
+ element="tns:getNullReturnGreetingsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getPersonGreetings">
+ <wsdl:part name="getPersonGreetings" element="tns:getPersonGreetings">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getPersonGreetingsResponse">
+ <wsdl:part name="getPersonGreetingsResponse" element="tns:getPersonGreetingsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getMultiGreetingsResponse">
+ <wsdl:part name="getMultiGreetingsResponse" element="tns:getMultiGreetingsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getObjectArrayGreeting">
+ <wsdl:part name="getObjectArrayGreeting" element="tns:getObjectArrayGreeting">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getArrayGreeting">
+ <wsdl:part name="getArrayGreeting" element="tns:getArrayGreeting">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getObjectArrayGreetingResponse">
+ <wsdl:part name="getObjectArrayGreetingResponse"
+ element="tns:getObjectArrayGreetingResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getMultiArrayGreetingsResponse">
+ <wsdl:part name="getMultiArrayGreetingsResponse"
+ element="tns:getMultiArrayGreetingsResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getObjectGreeting">
+ <wsdl:part name="getObjectGreeting" element="tns:getObjectGreeting">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getNullReturnGreetings">
+ <wsdl:part name="getNullReturnGreetings" element="tns:getNullReturnGreetings">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getMultiArrayGreetings">
+ <wsdl:part name="getMultiArrayGreetings" element="tns:getMultiArrayGreetings">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getMultiGreetings">
+ <wsdl:part name="getMultiGreetings" element="tns:getMultiGreetings">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="getArrayGreetingResponse">
+ <wsdl:part name="getArrayGreetingResponse" element="tns:getArrayGreetingResponse">
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="CheckedException">
+ <wsdl:part element="tns:CheckedException" name="fault" />
+ </wsdl:message>
+ <wsdl:portType name="HelloWorldService">
+ <wsdl:operation name="getPersonGreetings">
+ <wsdl:input message="tns:getPersonGreetings">
+ </wsdl:input>
+ <wsdl:output message="tns:getPersonGreetingsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNullReturnGreetings">
+ <wsdl:input message="tns:getNullReturnGreetings">
+ </wsdl:input>
+ <wsdl:output message="tns:getNullReturnGreetingsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getArrayGreeting">
+ <wsdl:input message="tns:getArrayGreeting">
+ </wsdl:input>
+ <wsdl:output message="tns:getArrayGreetingResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMultiArrayGreetings">
+ <wsdl:input message="tns:getMultiArrayGreetings">
+ </wsdl:input>
+ <wsdl:output message="tns:getMultiArrayGreetingsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMultiGreetings">
+ <wsdl:input message="tns:getMultiGreetings">
+ </wsdl:input>
+ <wsdl:output message="tns:getMultiGreetingsResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getObjectGreeting">
+ <wsdl:input message="tns:getObjectGreeting">
+ </wsdl:input>
+ <wsdl:output message="tns:getObjectGreetingResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getObjectArrayGreeting">
+ <wsdl:input message="tns:getObjectArrayGreeting">
+ </wsdl:input>
+ <wsdl:output message="tns:getObjectArrayGreetingResponse">
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="throwChecked">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ <wsdl:fault message="tns:CheckedException" name="CheckedException"/>
+ </wsdl:operation>
+ <wsdl:operation name="throwUnChecked">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="HelloWorldServiceBinding" type="tns:HelloWorldService">
+ <SOAP:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="getPersonGreetings">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getNullReturnGreetings">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getArrayGreeting">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMultiArrayGreetings">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getMultiGreetings">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getObjectGreeting">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ <wsdl:operation name="getObjectArrayGreeting">
+ <SOAP:operation />
+ <wsdl:input>
+ <SOAP:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <SOAP:body use="literal" />
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="HelloWorldServiceService">
+ <wsdl:port name="HelloWorldServicePort" binding="tns:HelloWorldServiceBinding">
+ <SOAP:address location="/HelloWorldServiceComponent1" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java
new file mode 100644
index 0000000000..c9609119c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 java.lang.RuntimeException: 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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/pom.xml
new file mode 100644
index 0000000000..d004ecbc26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite
new file mode 100644
index 0000000000..d700a92f20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsText/>
+ </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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsText/>
+ </binding.jms>
+ </service>
+ </component>
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/pom.xml
new file mode 100644
index 0000000000..e56246376f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java
new file mode 100644
index 0000000000..1acbfbd5ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java
new file mode 100644
index 0000000000..2d19d4bd82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java
new file mode 100644
index 0000000000..3ccd54e9bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b9a1ffd5ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..b92959cfd3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java
new file mode 100644
index 0000000000..ff5cf617f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..be2af78958
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 void throwChecked(String msg) throws CheckedException;
+ public void throwUnChecked(String msg);
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..e85d4ca5a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 void throwChecked(String msg) throws CheckedException {
+ throw new CheckedException("foo");
+ }
+
+ public void throwUnChecked(String msg) {
+ throw new RuntimeException("bla");
+ }
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite
new file mode 100644
index 0000000000..72e7646704
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService2" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </binding.jms>
+ </reference>
+ <reference name="helloWorldService3" >
+ <binding.jms>
+ <destination jndiName="HelloWorldService3"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </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>
+ <destination jndiName="HelloWorldService1"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </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>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </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>
+ <destination jndiName="HelloWorldService3"/>
+ <tuscany:wireFormat.jmsTextXML/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl
new file mode 100644
index 0000000000..53db66ea7e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl
@@ -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.
+-->
+<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="xsd:string" />
+
+ </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:fault message="tns:CheckedException" name="CheckedException"/>
+ </wsdl:operation>
+ <wsdl:operation name="throwUnChecked">
+ <wsdl:input message="tns:getPersonGreetingsRequest" name="getPersonGreetingsRequest"/>
+ </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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml
new file mode 100644
index 0000000000..d64cc46058
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..84ac2356db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:helloworld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite
new file mode 100644
index 0000000000..b8bc67d5e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService1"/>
+ <response>
+ <tuscany:wireFormat.jmsObject/>
+ </response>
+ <tuscany:wireFormat.jmsTextXML/>
+ </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>
+ <destination jndiName="HelloWorldService1"/>
+ <response>
+ <tuscany:wireFormat.jmsObject/>
+ </response>
+ <tuscany:wireFormat.jmsTextXML/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl
new file mode 100644
index 0000000000..935a2e73c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java
new file mode 100644
index 0000000000..8fc3d77cb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.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.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.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
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/pom.xml
new file mode 100644
index 0000000000..aefc85a28c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..90106d2cbf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:ServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.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/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite
new file mode 100644
index 0000000000..967754b6e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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:ObjectDest">
+ <tuscany:wireFormat.jmsObject /> <!-- test that wrapSingle default works -->
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/pom.xml
new file mode 100644
index 0000000000..9b7054cebe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..58ceeded7e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/main/resources/service.composite
new file mode 100644
index 0000000000..86bb60c147
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="RequestQueue"/>
+ <response>
+ <destination jndiName="ResponseQueue"/>
+ </response>
+ <tuscany:wireFormat.jmsObject/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java
new file mode 100644
index 0000000000..848e340181
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/pom.xml
new file mode 100644
index 0000000000..86bcce2990
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..7fed36fa77
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java
new file mode 100644
index 0000000000..7ab6019fd5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java
new file mode 100644
index 0000000000..89758becff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..eee9c86565
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Nulls"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..bb431a592b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/nulls.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/main/resources/nulls.composite
new file mode 100644
index 0000000000..e190cf92c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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: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:MyService2">
+ <tuscany:wireFormat.jmsObject/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java
new file mode 100644
index 0000000000..ac872f46a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/pom.xml
new file mode 100644
index 0000000000..16b133aae3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..360b365d1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:OneWayServiceComposite"/>
+ <deployable composite="itest:OneWayClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..8934614a8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite
new file mode 100644
index 0000000000..70a106bf06
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite
new file mode 100644
index 0000000000..5412a1d6e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/pom.xml
new file mode 100644
index 0000000000..ed8e7e93b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java
new file mode 100644
index 0000000000..9083ba1d9c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java
new file mode 100644
index 0000000000..3149f99a25
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..360b365d1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:OneWayServiceComposite"/>
+ <deployable composite="itest:OneWayClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite
new file mode 100644
index 0000000000..eeeb3b90d0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite
new file mode 100644
index 0000000000..e41e226994
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java
new file mode 100644
index 0000000000..14bbf238e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/pom.xml
new file mode 100644
index 0000000000..7564b32d33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a930b9e9a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:PropertiesClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/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/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml
new file mode 100644
index 0000000000..8c608adec9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/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://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <policySet name="JMSPolicySet1"
+ provides="priority"
+ appliesTo="sca:binding.jms">
+ <intentMap provides="priority" default="medium">
+ <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" default="nonPersistent">
+ <qualifier name="persistent">
+ <tuscany:jmsHeader JMSDeliveryMode="PERSISTENT"/>
+ </qualifier>
+ <qualifier name="nonPersistent">
+ <tuscany:jmsHeader JMSDeliveryMode="NON_PERSISTENT"/>
+ </qualifier>
+ </intentMap>
+ </policySet>
+
+</definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite
new file mode 100644
index 0000000000..f2761f0b78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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:ServiceQueue"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/pom.xml
new file mode 100644
index 0000000000..7183a4620d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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>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>callbacks</module>
+ <module>definitions</module>
+-->
+
+ </modules>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/properties/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/pom.xml
new file mode 100644
index 0000000000..86d26a4e3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java
new file mode 100644
index 0000000000..d4cd5df431
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java
new file mode 100644
index 0000000000..464072b42d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java
new file mode 100644
index 0000000000..4140fa0b89
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java
new file mode 100644
index 0000000000..2be4f2ad3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java
new file mode 100644
index 0000000000..d5684ca56c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java
new file mode 100644
index 0000000000..e18de0456c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..a930b9e9a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:PropertiesClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/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/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/properties/properties.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/main/resources/properties/properties.composite
new file mode 100644
index 0000000000..73f2a8eadc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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="6"
+ 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:ServiceQueue"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java
new file mode 100644
index 0000000000..29d5a345b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(6000);
+ }
+ }
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/pom.xml
new file mode 100644
index 0000000000..f45de031a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c062ef9ec0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:SimpleClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/client.composite
new file mode 100644
index 0000000000..3a03f9b675
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/cf/service.composite
new file mode 100644
index 0000000000..d7ba8f2838
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..a41e42950e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java
new file mode 100644
index 0000000000..03b834ce7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/pom.xml
new file mode 100644
index 0000000000..ccbf1b9a32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java
new file mode 100644
index 0000000000..9aef6ba1a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java
new file mode 100644
index 0000000000..430c71aaef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..2c6d9d0d17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c062ef9ec0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:SimpleClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/client.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/client.composite
new file mode 100644
index 0000000000..bed860e2cd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..01553a968c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java
new file mode 100644
index 0000000000..3c0eb0791b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/pom.xml
new file mode 100644
index 0000000000..6ea78d8107
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..b589d5e8bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java
new file mode 100644
index 0000000000..1aff0d454e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java
new file mode 100644
index 0000000000..fb53c877e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java
new file mode 100644
index 0000000000..1bbaf5d6f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java
new file mode 100644
index 0000000000..4bdc4edcb5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..59cf4aee9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite
new file mode 100644
index 0000000000..ab8e29ccdd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService2"/>
+ <tuscany:operationSelector.jmsdefault/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite
new file mode 100644
index 0000000000..af36b8af9b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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>
+ <destination jndiName="HelloWorldService4"/>
+ <operationProperties name="getGreetingsThree" nativeOperation="getGreetingsFour">
+ <headers>
+ <property name="blaNotUsed2">getGreetingsThree</property>
+ </headers>
+ </operationProperties>
+ <tuscany:operationSelector.jmsUserProp propertyName="myProperty"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..bb431a592b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/selectors/selectors.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/main/resources/selectors/selectors.composite
new file mode 100644
index 0000000000..bf10f20d38
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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: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: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:ServiceTopic" />
+ </service>
+ </component>
+
+ <component name="Service2">
+ <implementation.java class="org.apache.tuscany.sca.binding.jms.SelectorServiceImpl2"/>
+ <service name="SelectorService">
+ <binding.jms uri="jms: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:ServiceTopic" >
+ <messageSelection selector="JMSType = 'type2'"/>
+ </binding.jms>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java
new file mode 100644
index 0000000000..bee0c549bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java
new file mode 100644
index 0000000000..33e047ae18
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java
new file mode 100644
index 0000000000..e7254005be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/pom.xml
new file mode 100644
index 0000000000..9aed46d86e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>itest-jms-topics</artifactId>
+ <name>Apache Tuscany SCA JMS Tests for topics</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java
new file mode 100644
index 0000000000..b572b1012a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java
new file mode 100644
index 0000000000..9cec2d9b3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java
new file mode 100644
index 0000000000..0036391696
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..2690297524
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:TopicsClientComposite"/>
+ <deployable composite="itest:OneWayServiceComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..9888d5843b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsClient.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsClient.composite
new file mode 100644
index 0000000000..b951484044
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsService.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/main/resources/topics/TopicsService.composite
new file mode 100644
index 0000000000..80c653cc29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java
new file mode 100644
index 0000000000..35fe96b81a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/pom.xml
new file mode 100644
index 0000000000..49864fb06c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java
new file mode 100644
index 0000000000..336fecf67b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java
new file mode 100644
index 0000000000..dc6577b7e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java
new file mode 100644
index 0000000000..4f9908f062
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..eeae8fcc59
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:TTLTests"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..040ec282d7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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
+
+# 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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/ttl.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/main/resources/ttl.composite
new file mode 100644
index 0000000000..91b64cf8dc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java
new file mode 100644
index 0000000000..b5839f4c4f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/pom.xml
new file mode 100644
index 0000000000..7c938fb34f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..3349754e4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:SimpleServiceComposite"/>
+ <deployable composite="itest:URIClientComposite"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/jndi.properties b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/jndi.properties
new file mode 100644
index 0000000000..4d6acc037b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/service.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/service.composite
new file mode 100644
index 0000000000..01553a968c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite b/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite
new file mode 100644
index 0000000000..9e7b119fad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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:DestQueueA" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/pom.xml
new file mode 100644
index 0000000000..6eea2088c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..bf8a588928
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(){
+ System.out.println(">>>>>> " + sayHello("init"));
+ }
+
+ public String sayHello(String name) {
+ return "Hi " + service.sayHello(name);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b4ba94220c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:HelloworldClient"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite
new file mode 100644
index 0000000000..9d5e9ae59a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://itest"
+ name="HelloworldClient">
+
+ <component name="HelloworldClient">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ <reference name="service" target="HelloworldService"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/pom.xml
new file mode 100644
index 0000000000..ea5b2dc60a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..76f8d4400d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/pom.xml
new file mode 100644
index 0000000000..a7cdef93c6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java
new file mode 100644
index 0000000000..81f7e1747d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/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/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..c65718909d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:HelloworldService"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite b/tags/java/sca/2.0-M4-RC2/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite
new file mode 100644
index 0000000000..6b2d15b7a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://itest"
+ name="HelloworldService">
+
+ <component name="HelloworldService">
+ <implementation.java class="itest.nodes.HelloworldImpl"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/pom.xml
new file mode 100644
index 0000000000..99192513ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java
new file mode 100644
index 0000000000..6d49b718ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/nodes/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/pom.xml
new file mode 100644
index 0000000000..d08d2c9402
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/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-M4</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>one-node-test</module>
+ <module>two-nodes-test</module>
+ <module>two-nodes-two-vms-test</module>
+ </modules>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/pom.xml
new file mode 100644
index 0000000000..cefcd7d6ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java
new file mode 100644
index 0000000000..5f9453a5d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+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;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.oasisopen.sca.client.SCAClient;
+
+/**
+ * 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/200903";
+ 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 = SCAClient.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClient.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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java
new file mode 100644
index 0000000000..b413825106
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java
new file mode 100644
index 0000000000..4a41ae8133
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.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 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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java
new file mode 100644
index 0000000000..7dfa6e66cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java
new file mode 100644
index 0000000000..769aad1940
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.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 itest;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+
+import java.io.File;
+
+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.SCAClient;
+
+/**
+ * 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.newInstance();
+ 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 = SCAClient.getService(Helloworld.class, "HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClient.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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/build.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/build.xml
new file mode 100644
index 0000000000..933aec2636
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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>
+
+ <daemons>
+ <ant antfile="server.xml"/>
+ </daemons>
+
+ <sequential>
+ <sleep seconds="4"/>
+ <ant antfile="client.xml"/>
+ </sequential>
+
+ </parallel>
+
+ </target>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client-config.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client-config.xml
new file mode 100644
index 0000000000..21b03b97a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client-config.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.
+-->
+<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">
+
+ <!-- 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-M4.jar"/>
+ <contribution uri="client" location="../helloworld-client/target/itest-nodes-helloworld-client-2.0-M4.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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client.xml
new file mode 100644
index 0000000000..bb65805144
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/client.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">
+ <!--jvmarg value="-Djava.util.logging.config.file=../logging.properties"/-->
+ <arg value="-ttl"/>
+ <arg value="0"/>
+ <arg value="-node"/>
+ <arg value="./client-config.xml"/>
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/pom.xml
new file mode 100644
index 0000000000..b0e4c06ebb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/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-itest</artifactId>
+ <version>2.0-M4</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-endpoint-tribes</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>itest-nodes-helloworld-iface</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-axis2-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+ <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="runtime_classpath" refid="maven.runtime.classpath"/>
+ <ant antfile="./build.xml" target="run"/>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server-config.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server-config.xml
new file mode 100644
index 0000000000..14a48f507a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server-config.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.
+-->
+<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">
+
+ <!-- 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/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server.xml b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/server.xml
new file mode 100644
index 0000000000..7b6d206b7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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">
+ <!--jvmarg value="-Djava.util.logging.config.file=../logging.properties"/-->
+ <!--arg value="-ttl"/>
+ <arg value="0"/-->
+ <arg value="-node"/>
+ <arg value="./server-config.xml"/>
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java
new file mode 100644
index 0000000000..b27d16a562
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.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 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;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class TwoNodesTestCase {
+
+ private static Node serviceNode;
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+
+ serviceNode = factory.createNode(new File("server-config.xml").toURI().toURL());
+ serviceNode.start();
+
+ }
+
+ @Test
+ public void testNothing() throws Exception {
+
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (serviceNode != null) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/pom.xml
new file mode 100644
index 0000000000..3343eb9d58
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java b/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java
new file mode 100644
index 0000000000..1f589b44f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/resources/OperationOverload.composite b/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/main/resources/OperationOverload.composite
new file mode 100644
index 0000000000..cbf5aa2078
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/policies/pom.xml
new file mode 100644
index 0000000000..1e1ac8f072
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java
new file mode 100644
index 0000000000..fd33be01d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java
new file mode 100644
index 0000000000..368179dc29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java
new file mode 100644
index 0000000000..05ea341466
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java
new file mode 100644
index 0000000000..c9f50d08ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java
new file mode 100644
index 0000000000..cc7c555aff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java
new file mode 100644
index 0000000000..01cc8ac636
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java
new file mode 100644
index 0000000000..943720451f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java
new file mode 100644
index 0000000000..b712b99388
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Customer.composite b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Customer.composite
new file mode 100644
index 0000000000..2a8f598b90
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/LoggingMessages.properties b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/LoggingMessages.properties
new file mode 100644
index 0000000000..ada808be0e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/definitions.xml b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..0a39912bf0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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>
+
+</definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..be63597c12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:p="http://payment">
+ <deployable composite="p:Payment" />
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Payment.composite b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Payment.composite
new file mode 100644
index 0000000000..df54d0c1c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/policies/src/main/resources/Payment.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/200903"
+ xmlns:p="http://payment"
+ xmlns:c="http://customer"
+ xmlns:sca = "http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ requires = "sca:authorization"
+ targetNamespace="http://payment"
+ name="Payment">
+
+ <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" />
+ </component>
+
+ <component name="Customer">
+ <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/tags/java/sca/2.0-M4-RC2/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java
new file mode 100644
index 0000000000..3385ee9071
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/pom.xml
new file mode 100644
index 0000000000..fd5759d0aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/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-sca</artifactId>
+ <version>2.0-M4</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.5</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>builder</module>
+ <module>bpel</module>
+ <module>callback-api</module>
+ <module>callback-basic</module>
+ <module>callback-basic-ws</module>
+ <module>callback-complex-type</module>
+ <module>callback-multiple-wires</module>
+ <module>callback-separatethread</module>
+ <module>component-type</module>
+ <module>contribution-folder</module>
+ <module>contribution-zip</module>
+<!-- why commented out?
+ <module>definitions-multiple</module>
+-->
+ <module>distribution</module>
+ <module>exceptions</module>
+ <module>implementation-spring</module>
+ <module>interfaces</module>
+ <module>jms</module>
+ <module>nodes</module>
+<!-- why commented out?
+ <module>operation-overloading</module>
+-->
+<!-- wait until databinding-sdo is in
+ <module>properties</module>
+-->
+ <module>recursive-multi-level</module>
+ <module>references</module>
+ <module>scaclient-api</module>
+ <module>scopes</module>
+ <module>scdl</module>
+ <module>services</module>
+ <module>service-reference</module>
+ <module>wires</module>
+ <module>policies</module>
+ </modules>
+ </profile>
+
+ <profile>
+ <id>old</id>
+ <modules>
+ <module>bpel</module>
+ <module>builder</module>
+ <module>callablereferences</module>
+ <module>callablereferences-ws</module>
+ <module>callback-api</module>
+ <module>callback-basic</module>
+ <module>callback-complex-type</module>
+ <module>callback-id</module>
+ <module>callback-multiple-wires</module>
+ <module>callback-separatethread</module>
+ <module>callback-set-callback</module>
+ <module>callback-set-conversation</module>
+ <module>component-type</module>
+ <module>contribution</module>
+ <!--
+ <module>contribution-classloader</module>
+ -->
+ <module>contribution-import-export</module>
+ <module>conversations</module>
+ <module>conversations-ws</module>
+ <module>corba</module>
+ <module>databindings</module>
+ <module>exceptions</module>
+ <module>exceptions-cross-binding</module>
+ <module>exceptions-cross-binding-ws</module>
+ <module>exceptions-simple-ws</module>
+ <module>extended-api</module>
+ <module>interfaces</module>
+ <!--
+ <module>interop-soap-client</module>
+ <module>interop-soap-round2-client</module>
+ <module>interop-soap-service</module>
+ -->
+ <module>jms</module>
+ <module>jms-args</module>
+ <module>jms-callbacks</module>
+ <module>jms-definitions</module>
+ <module>jms-format</module>
+ <module>jms-selectors</module>
+ <module>large-sdo-ws</module>
+ <module>late-reference-resolution</module>
+ <module>oneway</module>
+ <module>operation-overloading</module>
+ <!--
+ <module>osgi-implementation</module>
+ <module>osgi-contribution</module>
+ -->
+ <module>policy</module>
+ <module>policy-security</module>
+ <module>policy-security-basicauth</module>
+ <module>policy-security-jsr250</module>
+ <module>policy-security-token</module>
+ <!--
+ <module>promotion-interface-missmatch</module>
+ -->
+ <module>properties</module>
+ <module>recursive</module>
+ <module>recursive-multi-level</module>
+ <module>recursive-ws</module>
+ <module>references</module>
+ <module>scopes</module>
+ <module>serialization</module>
+ <module>services</module>
+ <module>spring</module>
+ <module>transaction</module>
+ <module>validation</module>
+ <module>wires</module>
+ <module>wsdl</module>
+ <module>wsdl2java</module>
+ <module>wsdlless</module>
+ <module>wsdl-multiple</module>
+ <module>ws-void-args-return</module>
+ </modules>
+ </profile>
+ </profiles>
+
+ <modules>
+ <module>jaxws</module>
+ </modules>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/properties/pom.xml
new file mode 100644
index 0000000000..cdf4c0be74
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java
new file mode 100644
index 0000000000..b0fd64c9da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java
new file mode 100644
index 0000000000..7b44ef02e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java
new file mode 100644
index 0000000000..e8c4341cf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java
new file mode 100644
index 0000000000..68ce5a3cb6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java
new file mode 100644
index 0000000000..c8d0d4cae4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java
new file mode 100644
index 0000000000..b727935bc1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java
new file mode 100644
index 0000000000..e402131ce2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java
new file mode 100644
index 0000000000..52f9871d1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java
new file mode 100644
index 0000000000..fceda9d9ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java
new file mode 100644
index 0000000000..1642ab55f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java
new file mode 100644
index 0000000000..acd1f26670
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java
new file mode 100644
index 0000000000..71dce41efc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java
new file mode 100644
index 0000000000..9c7e8c3447
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java
new file mode 100644
index 0000000000..64ca749e9f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java
new file mode 100644
index 0000000000..a57ccd90c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java
new file mode 100644
index 0000000000..c147a2affe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java
new file mode 100644
index 0000000000..7c700903d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.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 Foo1 implements Bar {
+
+ @Property
+ protected String bar;
+
+ @Constructor( {"bar"})
+ public Foo1(String b) {
+ this.bar = b;
+ }
+
+ public String getBar() {
+ return this.bar;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java
new file mode 100644
index 0000000000..1d2e563095
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java
new file mode 100644
index 0000000000..54082e297a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java
new file mode 100644
index 0000000000..15fb49ea4e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java
new file mode 100644
index 0000000000..0a1d4a34a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/package-info.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/java/test/jaxb/props/package-info.java
new file mode 100644
index 0000000000..6a6fdd00cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/ConstructorPropertyInjection.composite b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
new file mode 100644
index 0000000000..af65f887c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/Outer.composite b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/Outer.composite
new file mode 100644
index 0000000000..5e767b1e0e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:foo="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903" 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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/OuterPropertyTest.composite b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/OuterPropertyTest.composite
new file mode 100644
index 0000000000..95ee1157bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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">
+ <foo:MyComplexValue xsi:type="foo:MyComplexType">
+ <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>
+ </foo:MyComplexValue>
+ </property>
+ </component>
+</composite>
+
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/PropertyTest.composite b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/PropertyTest.composite
new file mode 100644
index 0000000000..36f75d52a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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 xsi:type="foo:MyComplexType" >
+ <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:MyComplexValue/foo:a"/>
+ <property name="b" source="$complex/foo:MyComplexValue/foo:b"/>
+ <property name="f" source="$complex/foo:MyComplexValue/foo:a">f</property>
+ <property name="xpath" source="$complex/foo:MyComplexValue/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:MyComplexValue/foo:c"/>
+ <property name="d" source="$complex/foo:MyComplexValue/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:MyComplexValue/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">
+ <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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/customer.xsd b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/customer.xsd
new file mode 100644
index 0000000000..7421750f1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/fileProperty.txt b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/fileProperty.txt
new file mode 100644
index 0000000000..0d3d9ead83
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/manyValuesFileProperty.txt b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/manyValuesFileProperty.txt
new file mode 100644
index 0000000000..6d4180ee2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/manyValuesFileProperty.txt
@@ -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.
+-->
+<manyFilePropertyValues>fileValueOne</<manyFilePropertyValues>
+<manyFilePropertyValues>fileValueTwo</<manyFilePropertyValues>
+<manyFilePropertyValues>fileValueThree</<manyFilePropertyValues>
+<manyFilePropertyValues>fileValueFour</<manyFilePropertyValues>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/mySimpleService.composite b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/mySimpleService.composite
new file mode 100644
index 0000000000..3cf25384e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 ">
+
+
+ <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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcProps.txt b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcProps.txt
new file mode 100644
index 0000000000..052c291fd0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcprops.xsd b/tags/java/sca/2.0-M4-RC2/itest/properties/src/main/resources/rcprops.xsd
new file mode 100644
index 0000000000..21289fa7b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java
new file mode 100644
index 0000000000..efc635c72b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java
new file mode 100644
index 0000000000..0906a45ab3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java
new file mode 100644
index 0000000000..eb217600db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java
new file mode 100644
index 0000000000..a0213ced46
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/pom.xml
new file mode 100644
index 0000000000..00ff3be9e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <!--relativePath>../pom.xml</relativePath-->
+ </parent>
+ <artifactId>itest-recursive-multi-level</artifactId>
+ <name>Apache Tuscany SCA iTest Recusive Multi-Level</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java
new file mode 100644
index 0000000000..986c8305dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java
new file mode 100644
index 0000000000..6cad998042
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java
new file mode 100644
index 0000000000..261eff2584
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.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 MySimpleTotalService {
+ String getLocation();
+
+ String getYear();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java
new file mode 100644
index 0000000000..f3c9280f96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.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 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;
+
+ public String getLocation() {
+ return myService.getLocation();
+ }
+
+ public String getYear() {
+ return myService.getYear();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite
new file mode 100644
index 0000000000..090bc49a41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService1Auto.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/200903"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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"/>
+ </component>
+
+ <reference name="myServiceReference1Auto" promote="TotalServiceComponentLevel1Auto/myService">
+ <interface.java interface="mysca.test.myservice.MyService"/>
+ </reference>
+</composite>
+
diff --git a/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite
new file mode 100644
index 0000000000..8c1a9a2f72
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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"/>
+</composite> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite
new file mode 100644
index 0000000000..884a8b0a96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:foo="http://foo"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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">
+ </reference>
+
+</composite> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java
new file mode 100644
index 0000000000..b9b4e3ba7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.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 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.Ignore;
+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());
+ }
+
+ @Test
+ public void testLevel2() {
+ assertEquals("Default 2", myService2.getLocation());
+ assertEquals("1992", myService2.getYear());
+ }
+
+ @Test
+ public void testLevel3() {
+ assertEquals("Default 3", myService3.getLocation());
+ assertEquals("1993", myService3.getYear());
+ }
+
+ @AfterClass
+ public static void tearDown() {
+ node1.stop();
+ node2.stop();
+ node3.stop();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/references/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/references/pom.xml
new file mode 100644
index 0000000000..f094d7be82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java
new file mode 100644
index 0000000000..f8c0850118
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java
new file mode 100644
index 0000000000..cd0aad3eea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java
new file mode 100644
index 0000000000..785920bb2d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java
new file mode 100644
index 0000000000..211e6160f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java
new file mode 100644
index 0000000000..47a1f9bde8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java
new file mode 100644
index 0000000000..d436c28adc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java
new file mode 100644
index 0000000000..a1823e1cdc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java
new file mode 100644
index 0000000000..80617bdec2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java
new file mode 100644
index 0000000000..d181ac96ca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/AutoWiredReferencesTest.composite b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/AutoWiredReferencesTest.composite
new file mode 100644
index 0000000000..3934025e64
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/InnerReferencesTest.composite b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/InnerReferencesTest.composite
new file mode 100644
index 0000000000..871a846edf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/ManualWiredReferencesTest.composite b/tags/java/sca/2.0-M4-RC2/itest/references/src/main/resources/ManualWiredReferencesTest.composite
new file mode 100644
index 0000000000..52d6fe48c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java
new file mode 100644
index 0000000000..76264d308f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java
new file mode 100644
index 0000000000..6e4212fd9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java
new file mode 100644
index 0000000000..2fce95401e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/pom.xml
new file mode 100644
index 0000000000..48f14e6875
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldService.java
new file mode 100644
index 0000000000..1c7edaefb6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..4b9910bb21
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/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/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/Helloworld.composite b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/Helloworld.composite
new file mode 100644
index 0000000000..3f0e0a164c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d8604a5cc0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:itest="http://itest">
+ <deployable composite="itest:Helloworld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java
new file mode 100644
index 0000000000..a331e4dd22
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.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 test.scaclient;
+
+import itest.HelloworldService;
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.oasisopen.sca.client.SCAClient;
+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;
+
+ @Override
+ protected void setUp() throws Exception {
+ node = NodeFactory.newInstance().createNode();
+ node.start();
+ }
+
+ public void testInvoke() throws Exception {
+ HelloworldService service =
+ SCAClientFactory.newInstance(null).getService(HelloworldService.class, "HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ public void testSimpleAPI() throws Exception {
+ HelloworldService service = SCAClient.getService(HelloworldService.class, "/HelloworldComponent");
+ assertEquals("Hello petra", service.sayHello("petra"));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scdl/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/scdl/pom.xml
new file mode 100644
index 0000000000..21ded9671c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jsonp</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java
new file mode 100644
index 0000000000..c56545dd3b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/calculator/target/sample-calculator.jar");
+ URL url = file.toURI().toURL();
+ Monitor monitor = deployer.createMonitor();
+ Contribution contribution = deployer.loadContribution(url.toURI(), url, monitor);
+ deployer.build(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(1, 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/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java
new file mode 100644
index 0000000000..18fb9394bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.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.itest.scdl;
+
+import java.net.URL;
+
+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.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.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);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java
new file mode 100644
index 0000000000..44695e5dde
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.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.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:
+ * geronimo-stax-api_1.0_spec-1.0.1.jar
+ * jsr181-api-1.0-MR1.jar
+ * junit-4.5.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-common-java-2.0-SNAPSHOT.jar
+ * tuscany-common-xml-2.0-SNAPSHOT.jar
+ * tuscany-contribution-2.0-SNAPSHOT.jar
+ * tuscany-extensibility-2.0-SNAPSHOT.jar
+ * tuscany-implementation-bpel-2.0-SNAPSHOT.jar
+ * tuscany-implementation-java-2.0-SNAPSHOT.jar
+ * tuscany-interface-java-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-scdl-2.0-SNAPSHOT.jar
+ * tuscany-xsd-2.0-SNAPSHOT.jar
+ * wsdl4j-1.6.2.jar
+ * wstx-asl-3.2.4.jar
+ * XmlSchema-1.4.2.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(20, dependencyFiles.length);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/resources/test.composite b/tags/java/sca/2.0-M4-RC2/itest/scdl/src/test/resources/test.composite
new file mode 100644
index 0000000000..aa11c0d092
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/scopes/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/scopes/pom.xml
new file mode 100644
index 0000000000..50b70cf391
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java b/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java
new file mode 100644
index 0000000000..208ac3ba44
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java b/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java
new file mode 100644
index 0000000000..e6bf08ccf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/resources/scopes.composite b/tags/java/sca/2.0-M4-RC2/itest/scopes/src/main/resources/scopes.composite
new file mode 100644
index 0000000000..83a71218f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java
new file mode 100644
index 0000000000..594bdd5038
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/service-reference/pom.xml
new file mode 100644
index 0000000000..dab9279fb6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java
new file mode 100644
index 0000000000..8b5cf4d29a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java
new file mode 100644
index 0000000000..3f68ac828a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java
new file mode 100644
index 0000000000..18242cd594
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java
new file mode 100644
index 0000000000..dd143df036
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java
new file mode 100644
index 0000000000..fb436ae10c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java
new file mode 100644
index 0000000000..fc15b632d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java
new file mode 100644
index 0000000000..276093b69f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java
new file mode 100644
index 0000000000..84e15b5eb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java
new file mode 100644
index 0000000000..db99472385
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeA/CompositeA.composite b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeA/CompositeA.composite
new file mode 100644
index 0000000000..fb88cd8bea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeB/CompositeB.composite b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/nodeB/CompositeB.composite
new file mode 100644
index 0000000000..06e4c63e94
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite
new file mode 100644
index 0000000000..63302847b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java
new file mode 100644
index 0000000000..843afe207c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java
new file mode 100644
index 0000000000..1a454c939a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/services/pom.xml
new file mode 100644
index 0000000000..940c540f03
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java
new file mode 100644
index 0000000000..26e58dc530
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java
new file mode 100644
index 0000000000..627ff4976f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java
new file mode 100644
index 0000000000..d04bd1b985
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java
new file mode 100644
index 0000000000..01df89a8fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java
new file mode 100644
index 0000000000..07397e4502
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java
new file mode 100644
index 0000000000..8713e5ab22
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java
new file mode 100644
index 0000000000..842a85e000
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java
new file mode 100644
index 0000000000..8a3923b351
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java
new file mode 100644
index 0000000000..e52692fbf4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..e21261d8d0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:foo="http://foo">
+ <deployable composite="foo:InnerServicesTest" />
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/ServicesTest.composite b/tags/java/sca/2.0-M4-RC2/itest/services/src/main/resources/ServicesTest.composite
new file mode 100644
index 0000000000..e7d56032ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java
new file mode 100644
index 0000000000..da779b2c54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/wires/pom.xml b/tags/java/sca/2.0-M4-RC2/itest/wires/pom.xml
new file mode 100644
index 0000000000..48578c1bd5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java b/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java
new file mode 100644
index 0000000000..f5a4337254
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java b/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java
new file mode 100644
index 0000000000..82f0e26d58
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java b/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java
new file mode 100644
index 0000000000..67df1e3a52
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java b/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java
new file mode 100644
index 0000000000..f0308252ba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/resources/WireTest.composite b/tags/java/sca/2.0-M4-RC2/itest/wires/src/main/resources/WireTest.composite
new file mode 100644
index 0000000000..614beaec00
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java b/tags/java/sca/2.0-M4-RC2/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java
new file mode 100644
index 0000000000..2a0095cabc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..210611129b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,70 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA XML Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397124328
+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,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ 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.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.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/pom.xml
new file mode 100644
index 0000000000..f008d48cb1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
new file mode 100644
index 0000000000..da8c64b426
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -0,0 +1,782 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+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 = reader.getAttributeValue(null, 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("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 TODO
+ * @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
+ 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;
+ }
+ }
+ }
+
+ /**
+ * Write the value of a property
+ * @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) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new DOMSource(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());
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java
new file mode 100644
index 0000000000..b5fe005812
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java
new file mode 100644
index 0000000000..9a4a0dc035
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
new file mode 100644
index 0000000000..a878054d99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.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.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 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.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.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.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;
+
+/**
+ * A componentType processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<ComponentType> {
+
+ /**
+ * Constructs a new componentType processor.
+ *
+ * @param modelFactories
+ * @param extensionProcessor
+ * @param extensionAttributeProcessor
+ * @param monitor
+ */
+ public ComponentTypeProcessor(FactoryExtensionPoint modelFactories,
+ StAXArtifactProcessor extensionProcessor,
+ StAXAttributeProcessor extensionAttributeProcessor) {
+ super(modelFactories, extensionProcessor);
+ }
+
+ 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 {
+
+ // 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);
+ }
+
+ for (Object extension: service.getExtensions()) {
+ extensionProcessor.write(extension, writer, 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);
+ }
+
+ for (Object extension: reference.getExtensions()) {
+ extensionProcessor.write(extension, writer, 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);
+ }
+
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java
new file mode 100644
index 0000000000..f3f25f0b65
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.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.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.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;
+
+/**
+ * A composite processor.
+ *
+ * @version $Rev$ $Date$
+ */
+public class CompositeDocumentProcessor extends BaseAssemblyProcessor implements URLArtifactProcessor<Composite> {
+ 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, scdlStream, context);
+ }
+
+ public Composite read(URI uri, 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
+
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(scdlStream);
+ // 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());
+
+ reader.nextTag();
+
+ // 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
+ }
+ }
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java
new file mode 100644
index 0000000000..9b02df8b7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.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.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 = (Composite) map.get(qname);
+ if (resolved != null) {
+ return modelClass.cast(resolved);
+ }
+
+ // No definition found, 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);
+ }
+ }
+ }
+ }
+ return (T)unresolved;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
new file mode 100644
index 0000000000..026e0426af
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -0,0 +1,1065 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.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.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.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.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+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.xpath.XPathHelper;
+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.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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+
+/**
+ * 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;
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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;
+
+ }
+
+ 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(getString(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(getString(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 = getString(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);
+ }
+
+ } 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 = reader.getAttributeValue(null, 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);
+ }
+
+ } else if (PROPERTY_QNAME.equals(name)) {
+ if (component != null) {
+
+ // Read a <component><property>
+ componentProperty = assemblyFactory.createComponentProperty();
+ property = componentProperty;
+ String source = getString(reader, SOURCE);
+ if (source != null) {
+ source = source.trim();
+ }
+ componentProperty.setSource(source);
+ if (source != null) {
+ // $<name>/...
+ if (source.charAt(0) == '$') {
+ int index = source.indexOf('/');
+ if (index == -1) {
+ // Tolerating $prop
+ source = "";
+ } else {
+ source = source.substring(index + 1);
+ }
+ if ("".equals(source)) {
+ source = ".";
+ }
+ }
+
+ try {
+ componentProperty.setSourceXPathExpression(xpathHelper.compile(reader
+ .getNamespaceContext(), source));
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error(monitor, "ContributionReadException", source, ce);
+ //throw ce;
+ }
+ }
+ componentProperty.setFile(getString(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(getString(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(getString(reader, SOURCE));
+ wire.setSource(source);
+
+ ComponentService target = assemblyFactory.createComponentService();
+ target.setUnresolved(true);
+ target.setName(getString(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);
+
+ //handle extension attributes
+ this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor, context);
+
+ policyProcessor.readPolicies(callback, reader);
+
+ } 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 {
+
+ // 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;
+ }
+
+ 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
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer, 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()));
+
+ //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
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : service.getExtensions()) {
+ extensionProcessor.write(extension, writer, 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
+ for (Object extensions : callback.getExtensions()) {
+ extensionProcessor.write(extensions, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extensions : reference.getExtensions()) {
+ extensionProcessor.write(extensions, writer, 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
+ for (Object extension : callback.getExtensions()) {
+ extensionProcessor.write(extension, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+
+ // Write extensions
+ for (Object extension : reference.getExtensions()) {
+ extensionProcessor.write(extension, writer, 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("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("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);
+
+ // 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()) {
+ 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 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
+ implementation = resolveImplementation(implementation, resolver, context);
+
+ 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;
+ }
+
+ /**
+ * Returns the model factory extension point to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) {
+ return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ }
+
+ /**
+ * Returns the monitor to use.
+ *
+ * @param extensionPoints
+ * @return
+ */
+ private static Monitor monitor(ExtensionPointRegistry extensionPoints) {
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ if (utilities != null) {
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ if (monitorFactory != null) {
+ return monitorFactory.createMonitor();
+ }
+ }
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java
new file mode 100644
index 0000000000..bcba763c1c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java
new file mode 100644
index 0000000000..ad1e7cd83f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.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.xml;
+
+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/200903";
+ 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 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";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java
new file mode 100644
index 0000000000..198ddfbfeb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.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.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 = 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java
new file mode 100644
index 0000000000..4b9f07ae7e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.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.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.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();
+ 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);
+ Component component = (Component)endpoint.getComponent().clone();
+ composite.getComponents().add(component);
+ component.getReferences().clear();
+ component.getServices().clear();
+ ComponentService service = (ComponentService)endpoint.getService().clone();
+ component.getServices().add(service);
+ service.getBindings().clear();
+ service.setInterfaceContract(endpoint.getInterfaceContract());
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java
new file mode 100644
index 0000000000..dd1b6f5d62
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.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.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.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 = "endpointReference";
+ private final static QName ENDPOINT_QNAME = new QName(Constants.SCA11_TUSCANY_NS, ENDPOINT);
+
+ 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_QNAME;
+ }
+
+ public EndpointReference read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ 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.WIRED_TARGET_NOT_FOUND);
+ endpointReference.setUnresolved(true);
+ } else {
+ endpoint.setUnresolved(false);
+ endpoint.setBinding(reference.getBindings().get(0));
+ endpointReference.setStatus(EndpointReference.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_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.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java
new file mode 100644
index 0000000000..320c4eae62
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/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.assembly.xml;
+
+/**
+ * Constants for resource bundle names
+ */
+public interface Messages {
+ String RESOURCE_BUNDLE = "org.apache.tuscany.sca.assembly.xml.assembly-xml-validation-messages";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
new file mode 100644
index 0000000000..b47be74712
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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$
+ */
+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 attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readIntents(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject))
+ return;
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ readIntents(attachPoint, operation, reader);
+ readPolicySets(attachPoint, operation, reader);
+ }
+
+ /**
+ * Reads policy intents and policy sets.
+ * @param attachPoint
+ * @param reader
+ */
+ public void readPolicies(Object attachPoint, XMLStreamReader reader) {
+ readPolicies(attachPoint, null, reader);
+ }
+
+ /**
+ * Reads policy sets associated with an operation.
+ * @param attachPoint
+ * @param operation
+ * @param reader
+ */
+ private void readPolicySets(Object attachPoint, Operation operation, XMLStreamReader reader) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return;
+ }
+ PolicySubject policySubject = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint) throws XMLStreamException {
+ return writePolicies(attachPoint, (Operation)null);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, XMLStreamWriter writer) throws XMLStreamException {
+ writePolicyAttributes(attachPoint, (Operation)null, writer);
+ }
+
+ /**
+ * Write policies associated with an operation
+ * @param attachPoint
+ * @param operation
+ * @return
+ */
+ XAttr writePolicies(Object attachPoint, Operation operation) {
+ List<XAttr> attrs =new ArrayList<XAttr>();
+ attrs.add(writeIntents(attachPoint, operation));
+ attrs.add(writePolicySets(attachPoint, operation));
+ return new XAttr(null, attrs);
+ }
+
+ /**
+ * Write policies
+ * @param attachPoint
+ * @return
+ */
+ public void writePolicyAttributes(Object attachPoint, Operation operation, XMLStreamWriter writer) throws XMLStreamException {
+ XAttr attr = writePolicies(attachPoint, operation);
+ attr.write(writer);
+ }
+
+ /**
+ * Write policy intents associated with an operation.
+ * @param attachPoint
+ * @param operation
+ */
+ private XAttr writeIntents(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject intentAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint
+ * @param operation
+ */
+ private XAttr writePolicySets(Object attachPoint, Operation operation) {
+ if (!(attachPoint instanceof PolicySubject)) {
+ return null;
+ }
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+ 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 attachPoint, ModelResolver resolver, ProcessorContext context) {
+ if ( attachPoint instanceof PolicySubject ) {
+ PolicySubject policySetAttachPoint = (PolicySubject)attachPoint;
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java
new file mode 100644
index 0000000000..8ac0de9617
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.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.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.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 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/200903";
+ 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 = reader.getAttributeValue(null, 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..af59324c7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java
new file mode 100644
index 0000000000..d0a42be34e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java
new file mode 100644
index 0000000000..3058b1f5b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java
new file mode 100644
index 0000000000..b545e62469
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.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 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.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.policy.BindingType;
+import org.apache.tuscany.sca.policy.ImplementationType;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Processor for SCA Definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefinitionsProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Definitions> {
+ private StAXArtifactProcessor<Object> extensionProcessor;
+ private DefinitionsFactory definitionsFactory;
+
+ public static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ 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(FactoryExtensionPoint factoryExtensionPoint,
+ StAXArtifactProcessor<Object> extensionProcessor) {
+ this.extensionProcessor = extensionProcessor;
+ this.definitionsFactory = factoryExtensionPoint.getFactory(DefinitionsFactory.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 = reader.getAttributeValue(null, 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);
+ }
+ }
+ 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);
+ }
+
+ for (ImplementationType implementationType : scaDefns.getImplementationTypes()) {
+ extensionProcessor.resolve(implementationType, resolver, context);
+ }
+ }
+
+ public QName getArtifactType() {
+ return DEFINITIONS_QNAME;
+ }
+
+ public Class<Definitions> getModelType() {
+ return Definitions.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java
new file mode 100644
index 0000000000..38cc4a9de2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java
new file mode 100644
index 0000000000..70c71c5f1f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java
new file mode 100644
index 0000000000..95d8e67bf7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java
new file mode 100644
index 0000000000..ec4e17385f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
new file mode 100644
index 0000000000..ac4f81d5a9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java
@@ -0,0 +1,392 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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);
+ readExcludedIntents(intent, reader);
+
+ readConstrainedTypes(intent, reader);
+
+ 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.setType(intent.getType());
+ qualified.setName(new QName(qualifiedIntentName));
+ if (isDefault) {
+ intent.setDefaultQualifiedIntent(qualified);
+ }
+ intent.getQualifiedIntents().add(qualified);
+ 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));
+ }
+ 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 {
+ Monitor monitor = context.getMonitor();
+ 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) {
+ 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);
+ }
+ }
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java
new file mode 100644
index 0000000000..ee8b5274cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java
new file mode 100644
index 0000000000..979dad3c8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.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.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/200903";
+ 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 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);
+
+ String QUALIFIED_INTENT_CONSTRAINS_ERROR = " - Qualified Intents must not specify 'constrains' attribute";
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
new file mode 100644
index 0000000000..e647d1e575
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.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.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.List;
+import java.util.StringTokenizer;
+
+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));
+ 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);
+ //throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent 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);
+ 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;
+ }
+
+ 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);
+
+ policySet.getIntentMaps().add(intentMap);
+
+ 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?
+ }
+ }
+ }
+
+ }
+
+ 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 {
+ Monitor monitor = context.getMonitor();
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java
new file mode 100644
index 0000000000..10f142c67b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.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.policy.xml;
+
+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.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+
+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 (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 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;
+ }
+
+ private Boolean evaluateIntents(String[] intents, Node node) {
+ return Boolean.FALSE;
+ }
+
+ private static Pattern FUNCTION;
+ static {
+ String functionPattern = "(URIRef|InterfaceRef|OperationRef|MessageRef|IntentRefs)\\s*\\((.*)\\)";
+ FUNCTION = Pattern.compile(functionPattern);
+ }
+
+ public static String normalize(String attachTo) {
+ 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);
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java
new file mode 100644
index 0000000000..ca44667903
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml
new file mode 100644
index 0000000000..bbbbc93255
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..7927cc0f6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#componentType,model=org.apache.tuscany.sca.assembly.ComponentType
+org.apache.tuscany.sca.assembly.xml.CompositeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#composite,model=org.apache.tuscany.sca.assembly.Composite
+org.apache.tuscany.sca.assembly.xml.SCABindingProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#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#binding.rmi#endpoint,model=org.apache.tuscany.sca.assembly.Endpoint
+org.apache.tuscany.sca.assembly.xml.EndpointReferenceProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#binding.rmi#endpointReference,model=org.apache.tuscany.sca.assembly.EndpointReference
+org.apache.tuscany.sca.definitions.xml.DefinitionsProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#definitions,model=org.apache.tuscany.sca.definitions.Definitions
+org.apache.tuscany.sca.policy.xml.BindingTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#bindingType,model=org.apache.tuscany.sca.policy.BindingType
+org.apache.tuscany.sca.policy.xml.ImplementationTypeProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#implementationType,model=org.apache.tuscany.sca.policy.ImplementationType
+org.apache.tuscany.sca.policy.xml.IntentProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#intent,model=org.apache.tuscany.sca.policy.Intent
+org.apache.tuscany.sca.policy.xml.PolicySetProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#policySet,model=org.apache.tuscany.sca.policy.PolicySet
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
new file mode 100644
index 0000000000..f12e94d968
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties
@@ -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.
+#
+#
+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}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties
new file mode 100644
index 0000000000..857887ec3f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-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.
+#
+#
+ContributionReadException = ContributionReadException occured due to :
+PrivilegedActionException = Privileged Action Exception occured due to FilePermission in security policy file: \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
new file mode 100644
index 0000000000..d092b5959a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties
@@ -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.
+#
+#
+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 = Intent Map provides for Intent not specified as provided by parent PolicySet - {0}
+ContrainsAttributeMissing = Constrains attribute missing from Policy Intent Definition {0}
+RequiredIntentNotFound = 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 = 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}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java
new file mode 100644
index 0000000000..0d5e69bd61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java
new file mode 100644
index 0000000000..155c0c5a47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..b71764e0a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.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.assembly.xml;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+
+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);
+ 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);
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java
new file mode 100644
index 0000000000..05d320b211
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java
new file mode 100644
index 0000000000..9646356eb7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" " +
+ "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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java
new file mode 100644
index 0000000000..42730415b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java
new file mode 100644
index 0000000000..7787361e62
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java
new file mode 100644
index 0000000000..df588e3504
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java
new file mode 100644
index 0000000000..28e679da4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java
new file mode 100644
index 0000000000..b6f4c11ac2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..cfec8dee7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java
new file mode 100644
index 0000000000..cbfec53f65
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.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.xml;
+
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+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();
+ }
+
+ public DistributedSCABinding createDistributedSCABinding() {
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java
new file mode 100644
index 0000000000..2f13eb8b6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.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.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.Binding;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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, OptimizableBinding, PolicySubject {
+ private String name;
+ private String uri;
+ private List<Object> extensions = new ArrayList<Object>();
+
+ private Component targetComponent;
+ private ComponentService targetComponentService;
+ private Binding targetBinding;
+
+ 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();
+ }
+
+ /**
+ * @return the targetComponent
+ */
+ public Component getTargetComponent() {
+ return targetComponent;
+ }
+
+ /**
+ * @param targetComponent the targetComponent to set
+ */
+ public void setTargetComponent(Component targetComponent) {
+ this.targetComponent = targetComponent;
+ }
+
+ /**
+ * @return the targetComponentService
+ */
+ public ComponentService getTargetComponentService() {
+ return targetComponentService;
+ }
+
+ /**
+ * @param targetComponentService the targetComponentService to set
+ */
+ public void setTargetComponentService(ComponentService targetComponentService) {
+ this.targetComponentService = targetComponentService;
+ }
+
+ /**
+ * @return the targetBinding
+ */
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ /**
+ * @param targetBinding the targetBinding to set
+ */
+ public void setTargetBinding(Binding targetBinding) {
+ this.targetBinding = targetBinding;
+ }
+
+ 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/200903","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) {
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java
new file mode 100644
index 0000000000..543aaf9893
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
new file mode 100644
index 0000000000..a19ce79490
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java
new file mode 100644
index 0000000000..f50cd5811f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
new file mode 100644
index 0000000000..58e6e534b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..b1720ea8e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..a148e33029
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java
new file mode 100644
index 0000000000..f0bd5d8bde
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.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.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[sca:IntentRefs('sca:confidentiality')]";
+ str = normalize(str);
+ // 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')]"));
+ 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')]"));
+ 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')]"));
+ 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/200903";
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java
new file mode 100644
index 0000000000..c39dede56d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.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.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.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/200903", "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 static final String scaNamespace = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ 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");
+
+ @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);
+ }
+
+ 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));
+ }
+
+ 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());
+
+ 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);
+ }
+
+ //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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java
new file mode 100644
index 0000000000..aea2c3adb8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
new file mode 100644
index 0000000000..961a40b841
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..2f4518a42c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <service name="CalculatorService">
+ <interface.java interface="calculator.CalculatorService" />
+ </service>
+
+ <reference name="divideService">
+ <interface.java interface="calculator.DivideService" />
+ </reference>
+
+</componentType>
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite
new file mode 100644
index 0000000000..0d73d1a189
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite
new file mode 100644
index 0000000000..bf3676c585
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite
new file mode 100644
index 0000000000..9f40faa806
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
new file mode 100644
index 0000000000..807e256fc5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite
new file mode 100644
index 0000000000..8ca71a0580
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 ">
+
+ <!--
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
new file mode 100644
index 0000000000..5c7e4435bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 "
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml
new file mode 100644
index 0000000000..22c01b887a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+<!-- 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite
new file mode 100644
index 0000000000..4949cd017f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:calc="http://localcalc"
+ xmlns:test="http://testlocal"
+ targetNamespace="http://localcalc"
+ name="LocalCalculator"
+ local="true">
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml
new file mode 100644
index 0000000000..4325309463
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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/200903" 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/200903" 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/200903" 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/200903" 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/200903">
+ <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/200903" 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/200903" 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/200903" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
new file mode 100644
index 0000000000..dac8e384e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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/200903" 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/200903" 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/200903" 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/200903" 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/200903">
+ <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/200903" 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/200903" 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/200903" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
new file mode 100644
index 0000000000..d6082a936d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
new file mode 100644
index 0000000000..b4857c499f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -0,0 +1,204 @@
+<?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/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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/200903" 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/200903" 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/200903" 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/200903" 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/200903">
+ <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/200903" 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/200903" 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/200903" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/LICENSE
new file mode 100644
index 0000000000..2ea1dcc129
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/LICENSE
@@ -0,0 +1,337 @@
+
+ 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:
+
+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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..05f5c8471e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model XML Schemas
+Bnd-LastModified: 1225397088359
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/NOTICE
new file mode 100644
index 0000000000..78da9f5010
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/NOTICE
@@ -0,0 +1,38 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/pom.xml
new file mode 100644
index 0000000000..60448657bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <name>Apache Tuscany SCA Assembly Model XSD Files</name>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java
new file mode 100644
index 0000000000..b59cce55ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.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.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/200903";
+ 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-cd04.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("datatypes", Constants.class
+ .getResource("/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd"));
+ return cachedXSDs;
+ }
+ };
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema
new file mode 100644
index 0000000000..a919c3f2c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/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.
+#
+tuscany-sca-1.1.xsd
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd
new file mode 100644
index 0000000000..e8e8f7625a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd
new file mode 100644
index 0000000000..685e89a57e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd
new file mode 100644
index 0000000000..24e0b5a975
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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" "http://www.w3.org/2001/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd
new file mode 100644
index 0000000000..ac4b0ec8e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd
new file mode 100644
index 0000000000..16c791e533
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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" "http://www.w3.org/2001/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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd
new file mode 100644
index 0000000000..b5fc21e9c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd
@@ -0,0 +1,39 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <include schemaLocation="sca-core-1.1-cd04.xsd"/>
+
+ <include schemaLocation="sca-interface-java-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-interface-wsdl-1.1-cd04.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-cd03.xsd"/>
+ <include schemaLocation="sca-implementation-composite-1.1-cd04.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"/> <!-- New -->
+ <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-cd04.xsd"/>
+ <include schemaLocation="sca-binding-ejb-1.1-cd01.xsd"/>
+
+ <include schemaLocation="sca-definitions-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd04.xsd"/>
+
+ <include schemaLocation="sca-contribution-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd
new file mode 100644
index 0000000000..bcb9539c40
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd
@@ -0,0 +1,34 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd
new file mode 100644
index 0000000000..7f9baac45c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd
@@ -0,0 +1,173 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="connectionInfo" type="anyURI" use="optional" />
+ <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="name" type="NMTOKEN" 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="name" type="NMTOKEN" 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="nativeOperation" 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>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd
new file mode 100644
index 0000000000..b7f58705cd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd
@@ -0,0 +1,183 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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"/>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="correlationScheme" type="QName"
+ default="sca:messageId"/>
+ <attribute name="initialContextFactory" type="anyURI"/>
+ <attribute name="jndiURL" type="anyURI"/>
+ <attribute name="requestConnection" type="QName"/>
+ <attribute name="responseConnection" type="QName"/>
+ <attribute name="operationProperties" type="QName"/>
+ </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" use="required"/>
+ <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" use="required"/>
+ <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" use="required"/>
+ <attribute name="create" type="sca:JMSCreateResource"
+ use="optional" default="ifNotExist"/>
+ </complexType>
+
+ <complexType name="JMSResponse">
+ <sequence>
+ <element name="wireFormat" type="sca:WireFormatType" minOccurs="0"/>
+ <element name="destination" type="sca:JMSDestination" minOccurs="0"/>
+ <choice minOccurs="0">
+ <element name="connectionFactory" type="sca:JMSConnectionFactory"/>
+ <element name="activationSpec" type="sca:JMSActivationSpec"/>
+ </choice>
+
+ <!-- TUSCANY-3297 -->
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+
+ </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">
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="persistent"/>
+ <enumeration value="nonpersistent"/>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="timeToLive" type="long"/>
+ <attribute name="priority">
+ <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"/>
+ <attribute name="type" type="string" use="optional"
+ default="xs:string"/>
+ </extension>
+ </simpleContent>
+ </complexType>
+
+ <element name="binding.jms" type="sca:JMSBinding"
+ substitutionGroup="sca:binding"/>
+
+ <element name="wireFormat.jmsDefault" type="sca:WireFormatType"
+ substitutionGroup="sca:wireFormat"/>
+
+ <element name="operationSelector.jmsDefault" type="sca:OperationSelectorType"
+ substitutionGroup="sca:operationSelector"/>
+</schema> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd
new file mode 100644
index 0000000000..897e869806
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd
@@ -0,0 +1,20 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd
new file mode 100644
index 0000000000..24198c943d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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-cd04.xsd"/>
+
+ <element name="binding.ws" type="sca:WebServiceBinding"
+ substitutionGroup="sca:binding"/>
+
+ <complexType name="WebServiceBinding">
+ <complexContent>
+ <extension base="sca:Binding">
+ <sequence>
+ <element name="endpointReference" type="wsa:EndpointReferenceType"
+ minOccurs="0" maxOccurs="unbounded"/>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="wsdlElement" type="anyURI" use="optional"/>
+ <attribute ref="wsdli:wsdlLocation" use="optional"/>
+ </extension>
+ </complexContent>
+ </complexType>
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
new file mode 100644
index 0000000000..4bc2e73d4c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- (c) Copyright OASIS 2005, 2009. 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/200903"
+ elementFormDefault="qualified">
+
+ <element name="WSCallback">
+ <complexType>
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+ </element>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd
new file mode 100644
index 0000000000..f13fbd1567
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd
@@ -0,0 +1,90 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..7e2cd739fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2007,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..b808125568
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd
new file mode 100644
index 0000000000..1dcd515c98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd
@@ -0,0 +1,33 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-contribution-1.1-cd04.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="NCName" 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="NCName" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd
new file mode 100644
index 0000000000..74cfe9a739
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd
@@ -0,0 +1,534 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <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>
+ <!-- Comment out the sca:implementation to workaround http://www.mail-archive.com/dev@tuscany.apache.org/msg08924.html. -->
+ <!--
+ <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>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="constrainingType" type="QName" use="optional"/>
+ </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 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="constrainingType" type="QName" use="optional"/>
+ <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" />
+ <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"/>
+ </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">
+ <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="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="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="requires" type="sca:listOfQNames" use="optional"/>
+ <attribute name="policySets" type="sca:listOfQNames" use="optional"/>
+ </complexType>
+
+ <complexType name="Property" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <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="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ <!-- extension defines the place to hold default value -->
+ <!-- an extension point ; attribute-based only -->
+ </complexContent>
+ </complexType>
+
+ <!-- ConstrainingProperty is equivalent to the Property type but removes
+ the capability to contain a value -->
+ <complexType name="ConstrainingProperty" mixed="true">
+ <complexContent mixed="true">
+ <restriction base="sca:Property">
+ <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="mustSupply" type="boolean" use="optional"
+ default="false"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </restriction>
+ </complexContent>
+ </complexType>
+
+ <complexType name="PropertyValue" mixed="true">
+ <complexContent mixed="true">
+ <extension base="sca:SCAPropertyBase">
+ <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="source" type="string" use="optional"/>
+ <attribute name="file" type="anyURI" use="optional"/>
+ <attribute name="value" type="string" use="optional"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ <!-- an extension point ; attribute-based only -->
+ </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" />
+ </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">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <!-- OperationSelector Type -->
+ <element name="operationSelector" type="sca:OperationSelectorType" abstract="true"/>
+ <complexType name="OperationSelectorType" abstract="true">
+ <sequence>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <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"/>
+ <any namespace="##other" processContents="lax"/>
+ </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>
+ <!-- Set minOccurs="1" instead of "0" to workaround http://www.mail-archive.com/dev@tuscany.apache.org/msg08924.html. -->
+ <element ref="sca:implementation" minOccurs="1"/>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ComponentService"/>
+ <element name="reference" type="sca:ComponentReference"/>
+ <element name="property" type="sca:PropertyValue"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="autowire" type="boolean" use="optional"/>
+ <attribute name="constrainingType" type="QName" 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>
+
+ <!-- Constraining Service -->
+ <complexType name="ConstrainingService">
+ <complexContent>
+ <restriction base="sca:ComponentService">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required" />
+ </restriction>
+ </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>
+
+ <!-- Constraining Reference -->
+ <complexType name="ConstrainingReference">
+ <complexContent>
+ <restriction base="sca:ComponentReference">
+ <sequence>
+ <element ref="sca:interface" minOccurs="0" maxOccurs="1" />
+ <element ref="sca:callback" minOccurs="0" maxOccurs="1" />
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded" />
+ </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"/>
+ </restriction>
+ </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"/>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </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">
+ <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>
+
+ <!-- Constraining Type -->
+ <element name="constrainingType" type="sca:ConstrainingType"/>
+ <complexType name="ConstrainingType">
+ <complexContent>
+ <extension base="sca:CommonExtensionBase">
+ <sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element name="service" type="sca:ConstrainingService"/>
+ <element name="reference"
+ type="sca:ConstrainingReference"/>
+ <element name="property" type="sca:ConstrainingProperty"/>
+ </choice>
+ <any namespace="##other" processContents="lax" minOccurs="0"
+ maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="targetNamespace" type="anyURI"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <!-- 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd
new file mode 100644
index 0000000000..2034e4d2c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd
@@ -0,0 +1,31 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.xsd"/>
+ <include schemaLocation="sca-policy-1.1-cd04.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:binding"/>
+ <element ref="sca:bindingType"/>
+ <element ref="sca:implementationType"/>
+ <any namespace="##other" processContents="lax"
+ minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
+ <attribute name="targetNamespace" type="anyURI" use="required"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd
new file mode 100644
index 0000000000..11239e20d0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..011c7a61ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2007,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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="scope" type="sca:CImplementationScope"
+ use="optional" />
+ <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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CImplementationFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd
new file mode 100644
index 0000000000..e0524ee006
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd
@@ -0,0 +1,26 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..777da1e8ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <simpleType name="CPPImplementationScope">
+ <restriction base="string">
+ <enumeration value="stateless" />
+ <enumeration value="composite" />
+ </restriction>
+ </simpleType>
+
+ <complexType name="CPPImplementationFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="allowsPassByReference" type="boolean"
+ use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd
new file mode 100644
index 0000000000..53f6a0a51a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd
@@ -0,0 +1,27 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd
new file mode 100644
index 0000000000..51327ec84e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ elementFormDefault="qualified"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <include schemaLocation="sca-core-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd
new file mode 100644
index 0000000000..045118cb43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2007,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional" />
+ <attribute name="oneWay" 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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
new file mode 100644
index 0000000000..536b592c04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright(C) OASIS(R) 2006,2009. 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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="CPPFunction">
+ <attribute name="name" type="NCName" use="required" />
+ <attribute name="requires" type="sca:listOfQNames"
+ use="optional" />
+ <attribute name="oneWay" type="boolean" use="optional" />
+ <anyAttribute namespace="##other" processContents="lax" />
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd
new file mode 100644
index 0000000000..faf6d1cfb1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd
@@ -0,0 +1,29 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd
new file mode 100644
index 0000000000..980e4f90f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd
@@ -0,0 +1,29 @@
+<?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"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </extension>
+ </complexContent>
+ </complexType>
+
+</schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd
new file mode 100644
index 0000000000..6df685b881
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd
new file mode 100644
index 0000000000..a6cdfb2be5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd
@@ -0,0 +1,101 @@
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ elementFormDefault="qualified">
+
+ <include schemaLocation="sca-core-1.1-cd04.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" />
+ </sequence>
+ <attribute name="name" type="NCName" use="required"/>
+ <attribute name="default" type="boolean" use="optional"
+ default="false"/>
+ </complexType>
+
+ <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"
+ type="sca:PolicySetAttachment"/>
+ <complexType name="PolicySetAttachment">
+ <attribute name="name" type="QName" use="required"/>
+ <anyAttribute namespace="##other" processContents="lax"/>
+ </complexType>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd
new file mode 100644
index 0000000000..de7bc6bdd0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.xsd"/>
+
+ <element name="binding.dwr" type="t:DWRBinding"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd
new file mode 100644
index 0000000000..ce8d47b575
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.xsd"/>
+
+ <element name="binding.http" type="t:HTTPBinding"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd
new file mode 100644
index 0000000000..92142d117d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.xsd"/>
+
+ <element name="binding.jsonrpc" type="t:JSONRPCBinding"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd
new file mode 100644
index 0000000000..9b15010624
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.xsd"/>
+
+ <element name="binding.rmi" type="t:RMIBinding"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd
new file mode 100644
index 0000000000..dfe819d97f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.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/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
new file mode 100644
index 0000000000..7a8f45954f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd
@@ -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.
+-->
+<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/200903" schemaLocation="sca-1.1-cd04.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-binding-dwr.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-rmi.xsd"/>
+
+ <include schemaLocation="tuscany-sca-1.1-implementation-osgi.xsd"/>
+</schema> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/assembly/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/assembly/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a6327b2c98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/META-INF/MANIFEST.MF
@@ -0,0 +1,62 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Assembly Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397097203
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/assembly/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/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/tags/java/sca/2.0-M4-RC2/modules/assembly/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/assembly/pom.xml
new file mode 100644
index 0000000000..d5967c0e95
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java
new file mode 100644
index 0000000000..30e2592008
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.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;
+
+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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java
new file mode 100644
index 0000000000..fcad39d8cb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.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;
+
+import javax.xml.namespace.QName;
+
+/**
+ * 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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java
new file mode 100644
index 0000000000..a9ef26bbb9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java
new file mode 100644
index 0000000000..9ae511c07b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java
new file mode 100644
index 0000000000..7c0f7cf2ce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.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.assembly;
+
+/**
+ * A factory for the assembly model
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java
new file mode 100644
index 0000000000..96dc906395
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.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;
+
+/**
+ * Base interface for all assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Base {
+ String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java
new file mode 100644
index 0000000000..5c5827637d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.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;
+
+/**
+ * Represents a binding.
+ *
+ * @version $Rev$ $Date$
+ */
+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
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ QName getType();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java
new file mode 100644
index 0000000000..35e5f148ba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.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;
+
+/**
+ * TODO RRB experiment.
+ * Represents a binding implemented using Request/Response binding chains
+ * Used to test the RRB idea hence no integrated into the Binding interface, yet
+ *
+ * @version $Rev$ $Date$
+ */
+public interface BindingRRB extends Binding {
+
+ WireFormat getRequestWireFormat();
+
+ void setRequestWireFormat(WireFormat wireFormat);
+
+ WireFormat getResponseWireFormat();
+
+ void setResponseWireFormat(WireFormat wireFormat);
+
+ OperationSelector getOperationSelector();
+
+ void setOperationSelector(OperationSelector operationSelector);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java
new file mode 100644
index 0000000000..d34ec7d01f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.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;
+
+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();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java
new file mode 100644
index 0000000000..e2a68e2a4d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java
new file mode 100644
index 0000000000..9a6ae4d35a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.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;
+
+import javax.xml.xpath.XPathExpression;
+
+/**
+ * Represents a configured property of a component.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java
new file mode 100644
index 0000000000..b204b649fe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.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;
+
+/**
+ * An instance of a reference associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java
new file mode 100644
index 0000000000..022d829488
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.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.assembly;
+
+/**
+ * An addressable instance of a service associated with a particular component.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java
new file mode 100644
index 0000000000..2a09b5bc6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.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 java.util.List;
+
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * Describes an implementation and represents its configurable aspects.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java
new file mode 100644
index 0000000000..64a55f1b44
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java
new file mode 100644
index 0000000000..88cb2f9a2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java
new file mode 100644
index 0000000000..690316aca4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.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.assembly;
+
+/**
+ * Represents a composite service.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java
new file mode 100644
index 0000000000..9c8f6db912
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.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 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.
+ *
+ * @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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
new file mode 100644
index 0000000000..731c2986b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java
new file mode 100644
index 0000000000..6d8350fc66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java
new file mode 100644
index 0000000000..5cc43d6333
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.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 javax.xml.namespace.QName;
+
+/**
+ * Represents an SCA binding used in the distributed runtime.
+ * It provides us with a sensibly named type against which
+ * distributed sca binding providers can be registered
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DistributedSCABinding extends Binding {
+ QName TYPE = SCABinding.TYPE;
+
+ /**
+ * Return the wrapped SCA binding
+ * @return the SCA binding model element
+ */
+ SCABinding getSCABinding();
+
+ /**
+ * Set the wrapped SCA binding
+ * @param scaBinding the SCA binding model element
+ */
+ void setSCABinding(SCABinding scaBinding);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java
new file mode 100644
index 0000000000..59ab8d36fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.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.assembly;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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$
+ */
+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 getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Get the service's callback endpoint references that
+ * represent endpoint references from which callbacks
+ * originate
+ *
+ * @return callbackEndpoint the reference callback endpoint
+ */
+ List<EndpointReference> getCallbackEndpointReferences();
+
+ /**
+ * Set the extension point registry against the endpoint after it is deserialized as
+ * the registry needs to be re-attached
+ *
+ * @param registry
+ */
+ void setExtensionPointRegistry(ExtensionPointRegistry registry);
+
+ /**
+ * 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;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java
new file mode 100644
index 0000000000..7b547e70de
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.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.assembly;
+
+import java.io.Serializable;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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$
+ */
+public interface EndpointReference extends Base, PolicySubject, Cloneable, Serializable {
+
+ public static final int NOT_CONFIGURED = 0;
+ public static final int RESOLVED_BINDING = 1;
+ public static final int WIRED_TARGET_NOT_FOUND = 2;
+ public static final int WIRED_TARGET_FOUND_READY_FOR_MATCHING = 3;
+ public static final int WIRED_TARGET_FOUND_AND_MATCHED = 4;
+
+ /**
+ * 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 getInterfaceContract();
+
+ /**
+ * Sets the interface contract defining the interface
+ *
+ * @param interfaceContract the interface contract
+ */
+ void setInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * 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);
+
+ /**
+ * Returns true if this endpoint reference refers to an endpoint that
+ * is not running in this endpoint reference
+ *
+ * @return true if the endpoint is remote
+ */
+ boolean isRemote();
+
+ /**
+ * Set true if this endpoint reference refers to an endpoint that
+ * is not running in this endpoint reference
+ *
+ * @param remote set to true if the endpoint is remote
+ */
+ void setRemote(boolean remote);
+
+ /**
+ * Set the extension point registry against the endpoint after it is deserialized as
+ * the registry needs to be re-attached
+ *
+ * @param registry
+ */
+ void setExtensionPointRegistry(ExtensionPointRegistry registry);
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @return status
+ */
+ int getStatus();
+
+ /**
+ * Rather than relying on combinations of unresolved flags and
+ * other data we maintain a status enumeration
+ *
+ * @param status the new status
+ */
+ void setStatus(int status);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java
new file mode 100644
index 0000000000..9476251305
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.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;
+
+/**
+ * Base interface for extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java
new file mode 100644
index 0000000000..4d5b1a2ecd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.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.assembly;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Base interface for storing contents of extensible assembly model objects.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
new file mode 100644
index 0000000000..2d918a0592
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.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;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a component implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Implementation extends ComponentType {
+ QName getType();
+ List<Operation> getOperations();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java
new file mode 100644
index 0000000000..5d15ce9938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.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;
+
+/**
+ * Enumeration for multiplicity. Defines the number of wires that can connect a
+ * reference to target services.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java
new file mode 100644
index 0000000000..f72b78cc3a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.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 an operationSelector
+ *
+ * @version $Rev$ $Date$
+ */
+public interface OperationSelector extends Base, Cloneable {
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java
new file mode 100644
index 0000000000..947fcd4c7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.
+ *
+ * @version $Rev$ $Date$
+ */
+
+public interface OperationsConfigurator {
+ List<ConfiguredOperation> getConfiguredOperations();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java
new file mode 100644
index 0000000000..f997d03786
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.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;
+
+/**
+ * Represent a reference binding that supports optimized SCA local wiring between component
+ * references and services
+ *
+ * @version $Rev$ $Date$
+ *
+ */
+public interface OptimizableBinding extends Binding, Cloneable {
+
+ /**
+ * @param component
+ */
+ void setTargetComponent(Component component);
+
+ /**
+ * @param service
+ */
+ void setTargetComponentService(ComponentService service);
+
+ /**
+ * @param binding
+ */
+ void setTargetBinding(Binding binding);
+
+ /**
+ * @return
+ */
+ Binding getTargetBinding();
+
+ /**
+ * @return
+ */
+ Component getTargetComponent();
+
+ /**
+ * @return
+ */
+ ComponentService getTargetComponentService();
+
+ /**
+ * Clone the binding
+ * @return
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java
new file mode 100644
index 0000000000..9d1b3ac20c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.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;
+
+/**
+ * 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 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
new file mode 100644
index 0000000000..702826d43e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.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.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$
+ */
+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 a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @return true if the reference is a promotion override
+ */
+ boolean isPromotionOverride();
+
+ /**
+ * Sets a boolean value, "false" by default, which indicates whether
+ * the configuration of this reference is a promotion override for
+ * another more deeply nested reference.
+ *
+ * @param promotionOverride whether the reference is a promotion override
+ */
+ void setPromotionOverride(boolean promotionOverride);
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java
new file mode 100644
index 0000000000..aa356e3857
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java
new file mode 100644
index 0000000000..176770e553
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.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;
+
+/**
+ * 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();
+
+ DistributedSCABinding createDistributedSCABinding();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java
new file mode 100644
index 0000000000..5069b92a50
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.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 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$
+ */
+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();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java
new file mode 100644
index 0000000000..075b50eec1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java
new file mode 100644
index 0000000000..fc03bfeb88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.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 wireFormat.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WireFormat extends Base, Cloneable {
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
new file mode 100644
index 0000000000..5f10af6510
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.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.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$
+ */
+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 TODO
+ */
+ void build(Component component, Contract contract, B binding, BuilderContext context);
+
+ /**
+ * Get QName of the binding type
+ * @return
+ */
+ QName getBindingType();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java
new file mode 100644
index 0000000000..8a16fac9e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.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.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;
+
+/**
+ *
+ */
+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;
+ }
+
+ public BuilderContext(Monitor monitor) {
+ super();
+ this.monitor = monitor;
+ }
+
+ public BuilderContext(ExtensionPointRegistry registry) {
+ super();
+ MonitorFactory monitorFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java
new file mode 100644
index 0000000000..ae526b92a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.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.assembly.builder;
+
+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$
+ */
+public interface BuilderExtensionPoint {
+
+ /**
+ * 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);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java
new file mode 100644
index 0000000000..50bf10f54a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java
new file mode 100644
index 0000000000..5a2015f55e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java
new file mode 100644
index 0000000000..8afe493dec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.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.assembly.builder;
+
+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.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.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.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 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);
+ }
+
+ /**
+ * 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);
+ }
+
+
+ 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 <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) {
+ getBuilder().build(component, contract, binding, context);
+ }
+
+ 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 void build(Component component, Implementation implementation, BuilderContext context) {
+ getBuilder().build(component, implementation, context);
+ }
+
+ public QName getPolicyType() {
+ return qname;
+ }
+
+ 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 void build(Endpoint endpoint, BuilderContext context) {
+ getBuilder().build(endpoint, context);
+ }
+
+ public void build(org.apache.tuscany.sca.assembly.EndpointReference endpointReference, BuilderContext context) {
+ getBuilder().build(endpointReference, context);
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java
new file mode 100644
index 0000000000..6fa2d18037
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.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.builder;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * 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 DomainBuilder {
+
+ /**
+ * Wire up the references and service in a domain returning a list
+ * of the composites that have changed
+ *
+ * @param domainLevelCompsite
+ * @return a list of change composites
+ * @throws CompositeBuilderException
+ */
+ List<Composite> wireDomain(Composite domainLevelComposite);
+
+ /**
+ * Locates the referenced service and updates the URI on the identified binding
+ *
+ * @param domainLevelComposite
+ * @param referenceName
+ * @param bindingClassName
+ * @param URI
+ */
+ void updateDomainLevelServiceURI(Composite domainLevelComposite,
+ String referenceName,
+ String bindingClassName,
+ String URI);
+
+ /**
+ * Get the component name out of the reference name that might look like Component/Service
+ *
+ * @param referenceName
+ * @return
+ */
+ String getComponentNameFromReference(String referenceName);
+
+ /**
+ * Get the service name out of the reference name that might look like Component/Service
+ *
+ * @param referenceName
+ * @return
+ */
+ String getServiceNameFromReference(String referenceName);
+
+ /**
+ * Find the service object given a reference name
+ *
+ * @param composite
+ * @param referenceName
+ * @return
+ */
+ Service findServiceForReference(Composite composite, String referenceName);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
new file mode 100644
index 0000000000..b1e22e195d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java
new file mode 100644
index 0000000000..d40d72ae98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.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.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";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java
new file mode 100644
index 0000000000..2df42c2c23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.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.builder;
+
+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 languange to validate the configurations
+ * for SCA endpoints, endpoint references and component implementations
+ */
+public interface PolicyBuilder<T> {
+ QName getPolicyType();
+
+ /**
+ * Build (and validate) the policy settings on the endpoint
+ * @param endpoint
+ * @param monitor
+ */
+ void build(Endpoint endpoint, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the endpoint reference
+ * @param endpointReference
+ * @param monitor
+ */
+ void build(EndpointReference endpointReference, BuilderContext context);
+
+ /**
+ * Build (and validate) the policy settings on the component implementation
+ * @param component
+ * @param implementation
+ * @param monitor
+ */
+ void build(Component component, Implementation implementation, BuilderContext context);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
new file mode 100644
index 0000000000..49995f5ab8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.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.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+
+/**
+ * Represents an abstract property.
+ *
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty {
+ private Object value;
+ private String name;
+ private QName xsdType;
+ private QName xsdElement;
+ private boolean many;
+ private boolean mustSupply;
+
+ /**
+ * 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
new file mode 100644
index 0000000000..3e44f5f7ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
new file mode 100644
index 0000000000..24b1a0e03e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
new file mode 100644
index 0000000000..0759ff1361
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
new file mode 100644
index 0000000000..516b11724f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java
new file mode 100644
index 0000000000..552d67fec6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.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.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.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 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
new file mode 100644
index 0000000000..dcd6c7b08a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.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.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.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>();
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
new file mode 100644
index 0000000000..8a03df339c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
new file mode 100644
index 0000000000..9db522930f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
new file mode 100644
index 0000000000..78b54668b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
new file mode 100644
index 0000000000..f8c9f53413
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
new file mode 100644
index 0000000000..f18c852e69
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.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.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;
+ }
+
+ @Override
+ public int hashCode() {
+ return String.valueOf(getURI()).hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == this) {
+ return true;
+ } else {
+ if (obj instanceof ComponentType) {
+ if (getURI() != null) {
+ return getURI().equals(((ComponentType)obj).getURI());
+ } else {
+ return ((ComponentType)obj).getURI() == null;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public ExtensionType getExtensionType() {
+ return null;
+ }
+
+ public void setExtensionType(ExtensionType type) {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java
new file mode 100644
index 0000000000..fba6af7e7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java
new file mode 100644
index 0000000000..ae5fad461b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java
new file mode 100644
index 0000000000..55b48ec578
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java
new file mode 100644
index 0000000000..32377faf54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java
new file mode 100644
index 0000000000..2b72f1f047
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java
new file mode 100644
index 0000000000..99d68a11bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.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.assembly.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+
+/**
+ * The Distributed SCA binding wrapper for the SCA binding model object. This is currently
+ * just used to locate the remote binding extension and pass the SCA binding to the remote
+ * extension. It isn't used in the model itself
+ *
+ * @version $Rev$ $Date$
+ */
+public class DistributedSCABindingImpl implements DistributedSCABinding {
+
+ private SCABinding scaBinding;
+
+ public SCABinding getSCABinding() {
+ return scaBinding;
+ }
+
+ public void setSCABinding(SCABinding scaBinding) {
+ this.scaBinding = scaBinding;
+ }
+
+ public String getURI() {
+ return null;
+ }
+
+ public void setURI(String uri) {
+ }
+
+ public String getName() {
+ return null;
+ }
+
+ public void setName(String name) {
+
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java
new file mode 100644
index 0000000000..4b1d9e437d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.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.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.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 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 getInterfaceContract() {
+ resolve();
+ 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() {
+ 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;
+ }
+
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public boolean isRemote() {
+ return remote;
+ }
+
+ public void setRemote(boolean remote) {
+ this.remote = remote;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java
new file mode 100644
index 0000000000..4c02be42dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.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.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.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 ExtensionPointRegistry registry;
+ 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 boolean remote = false;
+ protected int status;
+
+ // 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 getInterfaceContract() {
+ resolve();
+ 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() {
+ 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() {
+ String output = "EndpointReference: ";
+
+ if (getURI() != null) {
+ output += " URI = " + getURI();
+ }
+
+ switch (status) {
+ case 0:
+ output += " NOT_CONFIGURED ";
+ break;
+ case 1:
+ output += " RESOLVED_BINDING ";
+ break;
+ case 2:
+ output += " WIRED_TARGET_NOT_FOUND ";
+ break;
+ case 3:
+ output += " WIRED_TARGET_FOUND_READY_FOR_MATCHING ";
+ break;
+ case 4:
+ output += " WIRED_TARGET_FOUND_AND_MATCHED ";
+ break;
+ }
+
+ if (targetEndpoint != null) {
+ output += " Target = " + targetEndpoint.toString();
+ }
+
+ return output;
+ }
+
+ 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;
+ }
+
+ public boolean isRemote() {
+ return remote;
+ }
+
+ public void setRemote(boolean remote) {
+ this.remote = remote;
+ }
+
+ protected void resolve() {
+ }
+
+ protected void reset() {
+ this.uri = null;
+ }
+
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java
new file mode 100644
index 0000000000..340fa2854c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java
new file mode 100644
index 0000000000..b5018c4d43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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;
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
new file mode 100644
index 0000000000..20c7ea3206
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.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.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$
+ */
+public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
+ private QName type;
+ private ExtensionType extensionType;
+ private 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java
new file mode 100644
index 0000000000..263af296b1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
new file mode 100644
index 0000000000..af4b3559c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.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.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 promotionOverride;
+ 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 boolean isPromotionOverride() {
+ return promotionOverride;
+ }
+
+ public void setPromotionOverride(boolean promotionOverride) {
+ this.promotionOverride = promotionOverride;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java
new file mode 100644
index 0000000000..cf7e744e88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.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.DistributedSCABinding;
+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();
+ }
+
+ public DistributedSCABinding createDistributedSCABinding() {
+ return new DistributedSCABindingImpl();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java
new file mode 100644
index 0000000000..b67dbcbb12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.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.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.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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, OptimizableBinding {
+ 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;
+
+ private Component targetComponent;
+ private ComponentService targetComponentService;
+ private Binding targetBinding;
+ private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+
+ public List<PolicySet> getApplicablePolicySets() {
+ return applicablePolicySets;
+ }
+
+ /**
+ * 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() {
+ if (targetComponentService == null) {
+ return true;
+ } else {
+ return targetComponentService.isUnresolved();
+ }
+ }
+
+ 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;
+ }
+
+ // Wireable binding operations
+
+ public Component getTargetComponent() {
+ return targetComponent;
+ }
+
+ public void setTargetComponent(Component targetComponent) {
+ this.targetComponent = targetComponent;
+ }
+
+ public ComponentService getTargetComponentService() {
+ return targetComponentService;
+ }
+
+ public void setTargetComponentService(ComponentService targetComponentService) {
+ this.targetComponentService = targetComponentService;
+ }
+
+ public Binding getTargetBinding() {
+ return targetBinding;
+ }
+
+ public void setTargetBinding(Binding targetBinding) {
+ this.targetBinding = targetBinding;
+ }
+
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
new file mode 100644
index 0000000000..62523e5c17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.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.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>();
+
+ /**
+ * 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java
new file mode 100644
index 0000000000..a4990f6a98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java
new file mode 100644
index 0000000000..156fd0af75
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java
new file mode 100644
index 0000000000..7a63bbedc5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.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.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;
+
+
+/**
+ * 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();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java
new file mode 100644
index 0000000000..5c68c6cbff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java
new file mode 100644
index 0000000000..f45be80888
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java
new file mode 100644
index 0000000000..616616ae7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java
new file mode 100644
index 0000000000..d87d45b27a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java
new file mode 100644
index 0000000000..224bc0a69a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.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.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.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>();
+
+
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java
new file mode 100644
index 0000000000..ead5ecba72
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.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.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);
+ }
+ }
+
+ 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);
+ }
+ }
+
+ 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);
+ }
+ }
+
+ 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);
+ }
+ }
+
+ target.getBindings().addAll(source.getBindings());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java
new file mode 100644
index 0000000000..247a432330
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.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;
+
+/**
+ * Enum of the Conversation Sequence values.
+ *
+ * @version $Rev$ $Date$
+ */
+public enum ConversationSequence {
+ CONVERSATION_NONE, CONVERSATION_START, CONVERSATION_CONTINUE, CONVERSATION_END
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java
new file mode 100644
index 0000000000..1f5620c0b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.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;
+
+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 semantially 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java
new file mode 100644
index 0000000000..70f6d5b403
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.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;
+
+/**
+ * This interface represents the mapping between WSDL faults and Java exceptions
+ *
+ * @version $Rev$ $Date$
+ */
+@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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java
new file mode 100644
index 0000000000..179dc1755e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java
new file mode 100644
index 0000000000..cab7057b57
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.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.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$
+ */
+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();
+
+ // FIXME: [rfeng] We need to re-consider the conversational as an intent
+ /**
+ * Test if the interface is conversational
+ * @return
+ */
+ boolean isConversational();
+
+ /**
+ * Set whether the interface is conversational
+ * @param conversational
+ */
+ void setConversational(boolean conversational);
+
+ /**
+ * 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 assoicated with the interface
+ * @return A map of attributes
+ */
+ Map<Object, Object> getAttributes();
+
+ /**
+ * Implementations must support cloning.
+ */
+ Object clone() throws CloneNotSupportedException;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java
new file mode 100644
index 0000000000..568a6c595c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.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;
+
+
+/**
+ * Interface contracts define one or more business functions. These business
+ * functions are provided by services and are used by references.
+ *
+ * @version $Rev$ $Date$
+ */
+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;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
new file mode 100644
index 0000000000..8dfeb29833
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.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.interfacedef;
+
+/**
+ * The InterfaceContractMapper is responsible to match interfaces
+ *
+ * @version $Rev$ $Date$
+ */
+public interface InterfaceContractMapper {
+ /**
+ * Check the compatibility of the source and the target interface contracts.
+ * <p>
+ * A wire may only connect a source to a target if the target implements an
+ * interface that is compatible with the interface required by the source.
+ * The source and the target are compatible if: <p/>
+ * <ol>
+ * <li>the source interface and the target interface MUST either both be
+ * remotable or they are both local
+ * <li>the methods on the target interface MUST be the same as or be a
+ * superset of the methods in the interface specified on the source
+ * <li>compatibility for the individual method is defined as compatibility
+ * of the signature, that is method name, input types, and output types MUST
+ * BE the same.
+ * <li>the order of the input and output types also MUST BE the same.
+ * <li>the set of Faults and Exceptions expected by the source MUST BE the
+ * same or be a superset of those specified by the service.
+ * <li>other specified attributes of the two interfaces MUST match,
+ * including Scope and Callback interface
+ * </ol>
+ * <p/>
+ * <p>
+ * This relationship implies that the source contract is a subset of the target
+ * contract - ie all the operations of the source must be present in the target, but
+ * the target can in principle contain additional operations not present in the
+ * source
+ * </p>
+ * <p>
+ * Please note this test is not symmetric: the success of isCompatible(A, B)
+ * does NOT imply isCompatible(B, A)
+ *
+ * @param source The source interface contract
+ * @param target The target interface contract
+ * @return true if the source contract can be supported by the target
+ * contract
+ */
+ boolean isCompatible(InterfaceContract source, InterfaceContract target);
+
+ /**
+ * 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.
+ * @param source - the source contract
+ * @param target - the target contract
+ * @return
+ */
+ boolean isEqual(InterfaceContract source, InterfaceContract target);
+
+ /**
+ * 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 an interface
+ * @param target a second interface
+ * @return true if the two interfaces are equal, otherwise return false
+ */
+ public boolean isEqual(Interface source, Interface target);
+
+ /**
+ * @param source
+ * @param target
+ * @param ignoreCallback
+ * @param silent
+ * @return
+ * @throws IncompatibleInterfaceContractException
+ */
+ boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ boolean ignoreCallback,
+ boolean silent) 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
+ * @return
+ */
+ boolean isCompatible(DataType<?> source, DataType<?> target, boolean remotable);
+
+ /**
+ * Check if source operation is compatible with the target operation
+ *
+ * @param source The source operation
+ * @param target The target operation
+ * @return true if the source operation is compatible with the target
+ * operation
+ */
+ boolean isCompatible(Operation source, Operation target, boolean remotable);
+
+ /**
+ * @param source
+ * @param target
+ * @return
+ */
+ boolean isCompatible(Interface source, Interface 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
+ */
+ Operation map(Interface target, Operation source);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java
new file mode 100644
index 0000000000..b24872bf96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.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;
+
+
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java
new file mode 100644
index 0000000000..f952a86478
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.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.interfacedef;
+
+
+/**
+ * Denotes an illegal callback interface
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class InvalidCallbackException extends InvalidInterfaceException {
+ private static final long serialVersionUID = 2727755895702116397L;
+
+ public InvalidCallbackException(String message) {
+ super(message);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
new file mode 100644
index 0000000000..2a273c9a26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public abstract class InvalidInterfaceException extends Exception {
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java
new file mode 100644
index 0000000000..b19805c5b1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.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.interfacedef;
+
+import java.lang.reflect.Method;
+
+/**
+ * Denotes an invalid conversational interface definition
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java
new file mode 100644
index 0000000000..55f00b82c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.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.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$
+ */
+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);
+
+ /**
+ * Get the sequence of the conversation
+ * @return
+ */
+ ConversationSequence getConversationSequence();
+
+ /**
+ * Set the sequence of conversation for the operation
+ * @param sequence
+ */
+ void setConversationSequence(ConversationSequence sequence);
+
+ /**
+ * Indicate if the operation is non-blocking
+ * @return
+ */
+ boolean isNonBlocking();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java
new file mode 100644
index 0000000000..6773b29088
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.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;
+
+import java.lang.reflect.Method;
+
+/**
+ * Exception thrown to indicate that a service contract specification contains
+ * an overloaded method.
+ *
+ * @version $Rev$ $Date$
+ */
+public class OverloadedOperationException extends InvalidInterfaceException {
+ private static final long serialVersionUID = -4658711318608885638L;
+ private final Method operation;
+
+ public OverloadedOperationException(Method operation) {
+ super(operation == null ?
+ null : "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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java
new file mode 100644
index 0000000000..c1c8400b71
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.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.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 semantially 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java
new file mode 100644
index 0000000000..15581b5e04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.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.interfacedef.impl;
+
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents an interface contract. InterfaceContractImpl
+ *
+ * @version $Rev$ $Date$
+ */
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
new file mode 100644
index 0000000000..289fd25594
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -0,0 +1,390 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class InterfaceContractMapperImpl implements InterfaceContractMapper {
+
+ public boolean isCompatible(DataType source, DataType target, boolean remotable) {
+ if (source == target) {
+ return true;
+ }
+ if (!remotable) {
+ if (source == null || target == null) {
+ return false;
+ }
+ // For local case
+ return target.getPhysical().isAssignableFrom(source.getPhysical());
+ } else {
+ // FIXME: How to test if two remotable data type is compatible?
+ // return target.getLogical().equals(source.getLogical());
+ return true;
+ }
+
+ }
+
+
+ /**
+ * 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 isEqual(InterfaceContract source, InterfaceContract target) {
+ // Are the forward interfaces equal?
+ if( isEqual( source.getInterface(), target.getInterface()) ) {
+ // Is there a Callback interface?
+ if( source.getCallbackInterface() == null && target.getCallbackInterface() == null ) {
+ return true;
+ } else {
+ if( isEqual( 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 isEqual(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.isConversational() != target.isConversational()) {
+ 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, source.isRemotable())) {
+ return false;
+ }
+ }
+ return true;
+ } // end method isEqual
+
+ public boolean isCompatible(Operation source, Operation target, boolean remotable) {
+ if (source == target) {
+ return true;
+ }
+
+ if (source.isDynamic() || target.isDynamic()) {
+ return true;
+ }
+
+ // Check name
+ if (!source.getName().equals(target.getName())) {
+ return false;
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ return false;
+ }
+
+ // 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;
+ }
+
+ if (checkSourceWrapper != checkTargetWrapper) {
+ return true;
+ }
+
+ if (!isCompatible(targetOutputType, sourceOutputType, remotable)) {
+ return false;
+ }
+
+ if (sourceInputType.size() != targetInputType.size()) {
+ return false;
+ }
+
+ int size = sourceInputType.size();
+ for (int i = 0; i < size; i++) {
+ if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), remotable)) {
+ 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, remotable)) {
+ // Target fault type can be covered by the source fault type
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ return false;
+ }
+ }
+
+ return 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;
+ }
+
+ public boolean checkCompatibility(InterfaceContract source,
+ InterfaceContract target,
+ boolean ignoreCallback,
+ boolean silent) throws IncompatibleInterfaceContractException {
+ if (source == target) {
+ // Shortcut for performance
+ return true;
+ }
+
+ if (source == null || target == null){
+ return false;
+ }
+
+ if (source.getInterface() == target.getInterface()){
+ return true;
+ }
+
+ if (source.getInterface() == null || target.getInterface() == null){
+ return false;
+ }
+
+ if (source.getInterface().isDynamic() || target.getInterface().isDynamic()) {
+ return true;
+ }
+
+ if (source.getInterface().isRemotable() != target.getInterface().isRemotable()) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Remotable settings do not match", source, target);
+ } else {
+ return false;
+ }
+ }
+ if (source.getInterface().isConversational() != target.getInterface().isConversational()) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Interaction scopes 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) {
+ throw new IncompatibleInterfaceContractException("Operation not found on target", source, target);
+ } else {
+ return false;
+ }
+ }
+ if (!source.getInterface().isRemotable()) {
+ // FIXME: for remotable operation, only compare name for now
+ if (!isCompatible(operation, targetOperation, false)) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Target operations are not compatible",
+ source, target);
+ } else {
+ return false;
+ }
+ }
+ }
+ }
+
+ if (ignoreCallback) {
+ return true;
+ }
+
+ 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", source, target);
+ } else {
+ return false;
+ }
+ }
+
+ if (source.getCallbackInterface().isConversational() != target.getCallbackInterface().isConversational()) {
+ if (!silent) {
+ throw new IncompatibleInterfaceContractException("Interaction scopes do not match", 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 isCompatible(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;
+ }
+ if (source.isConversational() != target.isConversational()) {
+ return false;
+ }
+
+ for (Operation operation : source.getOperations()) {
+ Operation targetOperation = getOperation(target.getOperations(), operation.getName());
+ if (targetOperation == null) {
+ return false;
+ }
+ if (!isCompatible(operation, targetOperation, source.isRemotable())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public boolean isCompatible(InterfaceContract source, InterfaceContract target) {
+ try {
+ return checkCompatibility(source, target, 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, target.isRemotable())) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
new file mode 100644
index 0000000000..08f859fc8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
new file mode 100644
index 0000000000..26144e92cb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.ConversationSequence;
+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$
+ */
+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 ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE;
+ 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 conversationSequence
+ */
+ public ConversationSequence getConversationSequence() {
+ return conversationSequence;
+ }
+
+ /**
+ * @param conversationSequence the conversationSequence to set
+ */
+ public void setConversationSequence(ConversationSequence conversationSequence) {
+ this.conversationSequence = conversationSequence;
+ }
+
+ /**
+ * @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);
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java
new file mode 100644
index 0000000000..777fa567f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.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.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema elements.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java
new file mode 100644
index 0000000000..844b0af509
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The generic java exception to wrap service faults
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java
new file mode 100644
index 0000000000..54c0a3ec11
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java
new file mode 100644
index 0000000000..2598dc8545
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.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.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * An abstraction of XML schema types
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java
new file mode 100644
index 0000000000..12db460959
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.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.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$
+ */
+public class WrapperInfo {
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java
new file mode 100644
index 0000000000..26ecf6e352
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.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.interfacedef.util;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The metadata for an XML element or type.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java
new file mode 100644
index 0000000000..f43c428563
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java
new file mode 100644
index 0000000000..2da41675a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java
new file mode 100644
index 0000000000..e7a93c8907
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.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;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Definition of extension type: binding or implementation
+ */
+public interface ExtensionType {
+ QName BINDING_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "binding");
+ QName IMPLEMENTATION_BASE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java
new file mode 100644
index 0000000000..d142015f57
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java
new file mode 100644
index 0000000000..b79ccdab78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java
new file mode 100644
index 0000000000..5b401baeb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java
new file mode 100644
index 0000000000..ee4f5b5236
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java
new file mode 100644
index 0000000000..a29f214f98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.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;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Interface that will abstract various types of policy specifications
+ * and attachments for example WS-Policy
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java
new file mode 100644
index 0000000000..9e7de2f6da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.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;
+
+/**
+ * A factory for the policy model.
+ *
+ * @version $Rev$ $Date$
+ */
+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();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java
new file mode 100644
index 0000000000..2b5b8458d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.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.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$
+ */
+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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java
new file mode 100644
index 0000000000..35a86ceedf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.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;
+
+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>
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java
new file mode 100644
index 0000000000..c1862283c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java
new file mode 100644
index 0000000000..1a2a9c5bad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java
new file mode 100644
index 0000000000..97fbc19ced
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java
new file mode 100644
index 0000000000..5c285e4d95
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
new file mode 100644
index 0000000000..27a77f3ba8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java
new file mode 100644
index 0000000000..6e2941ff5c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.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.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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java
new file mode 100644
index 0000000000..71e5eef6a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.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.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;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java
new file mode 100644
index 0000000000..c67ff1eab8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.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.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;
+
+/**
+ * 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();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java
new file mode 100644
index 0000000000..75d1229cd8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.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.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>();
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java
new file mode 100644
index 0000000000..102bea8d41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java
new file mode 100644
index 0000000000..f87938a5cb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.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.util;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+
+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
+ */
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..20189eae98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory
new file mode 100644
index 0000000000..ebbb4e93a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory
@@ -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.DefaultEndpointFactory
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory
new file mode 100644
index 0000000000..6e24d0bcfd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory
new file mode 100644
index 0000000000..c1cb41d967
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper
new file mode 100644
index 0000000000..e2da378609
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory
new file mode 100644
index 0000000000..6ff07189e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
new file mode 100644
index 0000000000..a9a252e08b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
@@ -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.
+#
+#
+DuplicateComponentName = 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 = Component implementation not resolved: Component = {0} Uri = {1}
+DuplicateImplementationPropertyName = Duplicate property name: Component = {0} Property = {1}
+DuplicateImplementationServiceName = Duplicate service name: Component = {0} Service = {1}
+DuplicateImplementationReferenceName = Duplicate reference name: Component = {0} Reference = {1}
+PropertyNotFound = Property not found for component property: Component = {0} Property = {1}
+PropertyMustSupplyIncompatible = Component property mustSupply attribute incompatible with property: Component = {0} Property = {1}
+PropertyMustSupplyNull = [ASM_4008] No value configured on a mustSupply property: Component = {0} Property = {1}
+PropertyOverrideManyAttribute = Component property many attribute incompatible with property: Component = {0} Property = {1}
+ReferenceNotFoundForComponentReference = Component type reference not found for component reference: Component = {0} Reference = {1}
+ReferenceIncompatibleMultiplicity = 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 = Component reference interface incompatible with implementation reference interface: Component = {0} Reference = {1} {2}
+ServiceIncompatibleComponentInterface = 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 = No targets for reference: Composite = {0} Reference = {1}
+PromotedReferenceNotFound = Promoted component reference not found: Composite = {0} Reference = {1}
+PromotedServiceNotFound = Promoted component service not found: Composite = {0} Service = {1}
+ComponentReferenceTargetNotFound = Component reference target not found, it might be a remote service running elsewhere in the SCA Domain: 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 = Composite {0} Component {1} Reference {2} must not specify endpoints using both target attribute and with binding uri attribute
+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 = Too many targets on reference: {0}
+ReferenceInterfaceNotSubSet = 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 = 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] 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 = 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} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties
new file mode 100644
index 0000000000..4cf9c01da5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = Duplicate intent {0} found in domain
+DuplicatePolicysSet = Duplicate policy set {0} found in domain
+DuplicateImplementationType = Duplicate implementation type {0} found in domain
+DuplicateBindingType = Duplicate binding type {0} found in domain
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java
new file mode 100644
index 0000000000..20fd74d46e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java
new file mode 100644
index 0000000000..5380a319d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.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;
+
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java
new file mode 100644
index 0000000000..6777c33ff1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java
new file mode 100644
index 0000000000..dbe0cb8225
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java
new file mode 100644
index 0000000000..24be8a3e7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java
new file mode 100644
index 0000000000..d94a7e93a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java
new file mode 100644
index 0000000000..acdaae799e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.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.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.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, 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, 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, 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, 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, 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, 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, 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, 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, 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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java
new file mode 100644
index 0000000000..d1faa5cf2b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java
new file mode 100644
index 0000000000..2775c4ac71
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.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.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"));
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..9d69acd1ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,48 @@
+Manifest-Version: 1.0
+Export-Package:
+ org.apache.tuscany.sca.binding.atom.collection
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA Abdera Atom Feed Binding Extension
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1254972865968
+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.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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..1b9052299c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/pom.xml
new file mode 100644
index 0000000000..6dc169f482
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/pom.xml
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http</artifactId>
+ <version>2.0-M4</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.7</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ <version>0.4.0-incubating</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>0.4.0-incubating</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>0.4.0-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-extensions-main</artifactId>
+ <version>0.4.0-incubating</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-extensions-json</artifactId>
+ <version>0.4.0-incubating</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
new file mode 100644
index 0000000000..c7552f932e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java
@@ -0,0 +1,515 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.DataExchangeSemantics;
+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, DataExchangeSemantics {
+
+ 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);
+ }
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
new file mode 100644
index 0000000000..5ba07f5e22
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java
@@ -0,0 +1,914 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.binding.http.HTTPCacheContext;
+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.RuntimeWire;
+
+/**
+ * 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 RuntimeWire 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(RuntimeWire 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.getCacheContextFromRequest( 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(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(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(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(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());
+ }
+ }
+ }
+
+
+ /**
+ *
+ * @param request
+ * @return
+ */
+ private static String getRequestPath(HttpServletRequest request) {
+ // Get the request path
+ String contextPath = request.getContextPath();
+ String servletPath = request.getServletPath();
+ String requestURI = request.getRequestURI();
+
+ int contextPathLength = request.getContextPath().length();
+ int servletPathLenght = servletPath.contains(contextPath) ? servletPath.length() - contextPath.length() : servletPath.length();
+
+ String requestPath = requestURI.substring(contextPathLength + servletPathLenght);
+
+ return requestPath;
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java
new file mode 100644
index 0000000000..6196a727ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.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.atom.provider;
+
+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.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;
+
+/**
+ * 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) {
+ 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(EndpointReference endpointReference) {
+ return new AtomReferenceBindingProvider(endpointReference, mediator);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new AtomServiceBindingProvider(endpoint, messageFactory, mediator, servletHost);
+ }
+
+ public Class<AtomBinding> getModelType() {
+ return AtomBinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java
new file mode 100644
index 0000000000..697a6140da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.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.atom.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Service;
+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.interfacedef.wsdl.WSDLInterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * Implementation of the Atom binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+class AtomServiceBindingProvider implements ServiceBindingProvider {
+ private MessageFactory messageFactory;
+
+ private Endpoint 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(Endpoint 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 = service.getInterfaceContract();
+ if (this.serviceContract instanceof WSDLInterfaceContract) {
+ for (Service componentService : component.getImplementation().getServices()) {
+ if (componentService.getName().equals(service.getName())) {
+ this.serviceContract = (InterfaceContract) componentService.getInterfaceContract();
+ break;
+ }
+ }
+
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return serviceContract;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ RuntimeComponentService componentService = (RuntimeComponentService)service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java
new file mode 100644
index 0000000000..19c100483c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.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.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();
+ scaConsumerNode.destroy();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ scaProviderNode.destroy();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java
new file mode 100644
index 0000000000..da7683d84a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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();
+ scaConsumerNode.destroy();
+ }
+ if (scaProviderNode != null) {
+ scaProviderNode.stop();
+ scaProviderNode.destroy();
+ }
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java
new file mode 100644
index 0000000000..e93c1aeea6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.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.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();
+ node.destroy();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java
new file mode 100644
index 0000000000..b707c71d2b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.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.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();
+ scaProviderNode.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java
new file mode 100644
index 0000000000..2870002c66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.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.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();
+ scaProviderNode.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java
new file mode 100644
index 0000000000..f802d3891f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.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.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();
+ node.destroy();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java
new file mode 100644
index 0000000000..534c2c901f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java
@@ -0,0 +1,433 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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();
+ scaProviderNode.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java
new file mode 100644
index 0000000000..b091045b8c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java
@@ -0,0 +1,387 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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();
+ scaProviderNode.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java
new file mode 100644
index 0000000000..98e4e0ee48
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.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.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();
+ node.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java
new file mode 100644
index 0000000000..5b9e0848a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.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.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();
+ node.destroy();
+ }
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif
new file mode 100644
index 0000000000..bfeee9b2f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg
new file mode 100644
index 0000000000..584f39ea8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite
new file mode 100644
index 0000000000..fa80fc0a39
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite
new file mode 100644
index 0000000000..c029cef2fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite
new file mode 100644
index 0000000000..a50a876ac4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite
new file mode 100644
index 0000000000..090336bc5d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite
new file mode 100644
index 0000000000..35e25957fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite
new file mode 100644
index 0000000000..49d98f83cf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..3a3d6bd22b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.atom;
+ uses:="org.apache.tuscany.sca.assembly";version="2.0.0"
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA Atom Feed Binding Extension
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1254972834027
+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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory
new file mode 100644
index 0000000000..a8117db8f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..00a4dfe0d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/pom.xml
new file mode 100644
index 0000000000..7177555c20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java
new file mode 100644
index 0000000000..7ac6e05bc9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java
new file mode 100644
index 0000000000..6e5623e1a2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java
new file mode 100644
index 0000000000..91cd89e98d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.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.atom.impl;
+
+import javax.xml.namespace.QName;
+
+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 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;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ 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 QName getType() {
+ return AtomBinding.TYPE;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java
new file mode 100644
index 0000000000..6b8ff10d1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.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;
+
+import java.io.StringReader;
+
+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;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AtomBindingProcessorTestCase extends TestCase {
+
+ private static final String COMPOSITE =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>"
+ + "<composite xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\" 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 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);
+ AtomBinding binding = (AtomBinding) composite.getComponents().get(0).getServices().get(0).getBindings().get(0);
+
+ assertNotNull(binding);
+ assertEquals("Feed Title", binding.getTitle());
+ assertEquals("http://localhost:8080/feed", binding.getURI());
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b203986264
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,41 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA EJB Binding Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397250828
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/pom.xml
new file mode 100644
index 0000000000..de4fc9c4bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java
new file mode 100644
index 0000000000..9247c1d3db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.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.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.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+
+/**
+ * EJBTargetInvoker
+ *
+ * @version $Rev$ $Date$
+ */
+public class EJBBindingInvoker implements Invoker, DataExchangeSemantics {
+
+ 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);
+
+ String methodName = operation.getName();
+
+ // invoke business method on ejb
+ Object response = ejbHandler.invoke(methodName, (Object[])payload);
+
+ return response;
+ }
+
+ protected NamingEndpoint getNamingEndpoint() {
+ return new NamingEndpoint(location);
+ }
+
+ public boolean allowsPassByReference() {
+ // EJB RMI/IIOP always pass by value
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java
new file mode 100644
index 0000000000..f2647bdd2e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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;
+
+/**
+ * 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(EndpointReference endpointReference) {
+ return new EJBBindingReferenceBindingProvider((RuntimeComponent)endpointReference.getComponent(),
+ (RuntimeComponentReference)endpointReference.getReference(),
+ (EJBBinding)endpointReference.getBinding());
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ // Service Binding not supported for EJB Binding
+ return null;
+ }
+
+ public Class<EJBBinding> getModelType() {
+ return EJBBinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties
new file mode 100644
index 0000000000..28477dd3ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java
new file mode 100644
index 0000000000..337bb004b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/Customer.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/Customer.java
new file mode 100644
index 0000000000..8585301868
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java
new file mode 100644
index 0000000000..7406b9bd37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..7cefba530a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddService.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 calculator;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface AddService {
+ double add(double n1, double n2);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java
new file mode 100644
index 0000000000..799bcaa672
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java
new file mode 100644
index 0000000000..87616330dc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.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.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();
+ node.destroy();
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/resources/account/account.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb-runtime/src/test/resources/account/account.composite
new file mode 100644
index 0000000000..943f82c0ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a8bd2b925f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA EJB Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397146656
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/pom.xml
new file mode 100644
index 0000000000..2c997ac21e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java
new file mode 100644
index 0000000000..cfaaeb284c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java
new file mode 100644
index 0000000000..6e2c8d358f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java
new file mode 100644
index 0000000000..13b069a6bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java
new file mode 100644
index 0000000000..c4a51f93a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.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.binding.ejb.impl;
+
+import javax.xml.namespace.QName;
+
+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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java
new file mode 100644
index 0000000000..af0eb8ea08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.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.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.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 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 = reader.getAttributeValue(null, 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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..70d2398d71
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#binding.ejb,model=org.apache.tuscany.sca.binding.ejb.EJBBinding
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties
new file mode 100644
index 0000000000..28477dd3ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml
new file mode 100644
index 0000000000..1d55a38a2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b29dc9bc59
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,27 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.http.provider;version="2.0.
+ 0",.;version="2.0.0"
+Tool: Bnd-0.0.311
+Bundle-Name: Apache Tuscany SCA HTTP Binding Runtime
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1253494834368
+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.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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/pom.xml
new file mode 100644
index 0000000000..782ba208e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-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-M4</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-M4</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security-http</artifactId>
+ <version>1.6-SNAPSHOT</version>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</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-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java
new file mode 100644
index 0000000000..80881f7859
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java
@@ -0,0 +1,453 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.ServletResponse;
+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.http.HTTPCacheContext;
+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 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.getCacheContextFromRequest(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());
+ }
+
+ // 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.getCacheContextFromRequest(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.getCacheContextFromRequest(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.getCacheContextFromRequest(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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java
new file mode 100644
index 0000000000..53383af35e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.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.http.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.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;
+
+
+/**
+ * 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;
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) {
+ // Binding HTTP is currently NOT supporting References
+ return null;
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new HTTPServiceBindingProvider(endpoint, extensionPoints, messageFactory, servletHost);
+ }
+
+ public Class<HTTPBinding> getModelType() {
+ return HTTPBinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
new file mode 100644
index 0000000000..8342dd64c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.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.http.provider;
+
+import javax.servlet.Servlet;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
+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.RuntimeWire;
+
+/**
+ * Implementation of an HTTP binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class HTTPServiceBindingProvider implements ServiceBindingProviderRRB {
+ private ExtensionPointRegistry extensionPoints;
+
+ private Endpoint 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(Endpoint 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(component, service, binding);
+ }
+ }
+
+ 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(component, service, binding);
+ }
+ }
+
+
+
+ //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
+ RuntimeComponentService componentService = (RuntimeComponentService) service;
+ RuntimeWire wire = componentService.getRuntimeWire(binding);
+ Servlet servlet = null;
+ bindingListenerServlet = new HTTPBindingListenerServlet(binding, messageFactory );
+ for (InvocationChain invocationChain : wire.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
+ * @param runtimeWire
+ */
+ public void configureBindingChain(RuntimeWire runtimeWire) {
+
+ InvocationChain bindingChain = runtimeWire.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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java
new file mode 100644
index 0000000000..41cf245735
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.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 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();
+ node.destroy();
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java
new file mode 100644
index 0000000000..b5850b7670
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.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.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();
+ node.destroy();
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java
new file mode 100644
index 0000000000..f2456f3175
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.java
new file mode 100644
index 0000000000..fec68138a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.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 TestServiceCacheImpl 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/content/test.html b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/test.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/test.composite
new file mode 100644
index 0000000000..1fb8fce37e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/testCache.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-http-runtime/src/test/resources/testCache.composite
new file mode 100644
index 0000000000..277556dab4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-http/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-http/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-http/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5336512666
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+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
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1253494834368
+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/tags/java/sca/2.0-M4-RC2/modules/binding-http/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-http/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-http/pom.xml
new file mode 100644
index 0000000000..63d76e422f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <!--
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>1.6-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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java
new file mode 100644
index 0000000000..f3f309a19b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.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.http;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.BindingRRB;
+
+
+/**
+ * HTTP binding model.
+ *
+ * @version $Rev$ $Date$
+*/
+public interface HTTPBinding extends BindingRRB {
+ QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.http");
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java
new file mode 100644
index 0000000000..6ba6d8f934
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java
new file mode 100644
index 0000000000..372118fbf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.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.binding.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.
+
+ */
+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;
+
+ /**
+ * 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();
+ }
+
+ /**
+ * Gets the cache context information (ETag, LastModified, predicates) from the Http request.
+ * @param request
+ * @return
+ */
+ public static HTTPCacheContext getCacheContextFromRequest( 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java
new file mode 100644
index 0000000000..056bb8a75e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = getString(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/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fd69b62555
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,38 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JMS Binding Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+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,
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/pom.xml
new file mode 100644
index 0000000000..df64375975
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/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-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java
new file mode 100644
index 0000000000..923d9aa1d1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.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.binding.jms.headers;
+
+
+
+
+import java.util.Map;
+
+import javax.jms.DeliveryMode;
+import javax.jms.JMSException;
+
+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.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.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class HeaderReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private String correlationScheme;
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+
+ public HeaderReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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();
+ RuntimeComponentReference reference = (RuntimeComponentReference)runtimeWire.getEndpointReference().getReference();
+
+ // 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, callbackDestName);
+ }
+ }
+
+ 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);
+ }
+ }
+
+
+ protected String getCallbackDestinationName(RuntimeComponentReference reference) {
+ RuntimeComponentService s = (RuntimeComponentService)reference.getCallbackService();
+ JMSBinding b = s.getBinding(JMSBinding.class);
+ if (b != null) {
+ JMSBindingServiceBindingProvider bp = (JMSBindingServiceBindingProvider)s.getBindingProvider(b);
+ return bp.getDestinationName();
+ }
+ return null;
+ }
+
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java
new file mode 100644
index 0000000000..7de30c265a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java
new file mode 100644
index 0000000000..f120055dde
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.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.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: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $
+ */
+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) {
+ 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 (!"Transport disposed.".equals(e.getMessage())) {
+ 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
+ if (destination == null) {
+ 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");
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java
new file mode 100644
index 0000000000..a4a7ff5e5d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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();
+
+ MessageListener listener = new DefaultServiceInvoker(jmsSLD.getJmsBinding(), jmsSLD.getService(), jmsSLD.getTargetBinding(), jmsSLD.getMessageFactory(), rf);
+ RuntimeComponentService service = jmsSLD.getService();
+
+// 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java
new file mode 100644
index 0000000000..02f4f1bf1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.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.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.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;
+
+/**
+ * TODO RRB experiement
+ * Listener for the JMSBinding.
+ *
+ * @version $Rev: 721811 $ $Date: 2008-11-30 13:46:51 +0000 (Sun, 30 Nov 2008) $
+ */
+public class DefaultServiceInvoker implements MessageListener {
+
+ private static final Logger logger = Logger.getLogger(DefaultServiceInvoker.class.getName());
+
+ private JMSBinding jmsBinding;
+ private Binding targetBinding;
+ private JMSResourceFactory jmsResourceFactory;
+ private RuntimeComponentService service;
+ private MessageFactory messageFactory;
+
+ public DefaultServiceInvoker(JMSBinding jmsBinding, RuntimeComponentService service, Binding targetBinding, MessageFactory messageFactory, JMSResourceFactory rf) throws NamingException {
+ this.jmsBinding = jmsBinding;
+ this.jmsResourceFactory = rf;
+ this.service = service;
+ 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
+ service.getRuntimeWire(targetBinding).invoke(tuscanyMsg);
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java
new file mode 100644
index 0000000000..e4bf31f7ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java
new file mode 100644
index 0000000000..b6ccb5be9b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java
new file mode 100644
index 0000000000..2942f93781
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.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.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public interface JMSServiceListenerDetails {
+
+ JMSBinding getJmsBinding();
+
+ Binding getTargetBinding();
+
+ RuntimeComponentService getService();
+
+ RuntimeComponent getComponent();
+
+ MessageFactory getMessageFactory();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java
new file mode 100644
index 0000000000..5f3f773985
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java
new file mode 100644
index 0000000000..d2edae4d23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.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.operationselector.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSDefault> {
+ private ExtensionPointRegistry registry;
+
+ public OperationSelectorJMSDefaultProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return null;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new OperationSelectorJMSDefaultServiceProvider(component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java
new file mode 100644
index 0000000000..8efd75d40d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.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.binding.jms.operationselector.jmsdefault.runtime;
+
+import java.io.ByteArrayInputStream;
+import java.io.StringReader;
+import java.util.List;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+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.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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultServiceInterceptor implements Interceptor {
+
+ private static final String ON_MESSAGE_METHOD_NAME = "onMessage";
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+
+
+ public OperationSelectorJMSDefaultServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory,
+ RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+ this.service = (RuntimeComponentService)runtimeWire.getEndpoint().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();
+
+ 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) {
+
+ OMElement rootElement;
+ String operationFromPayload;
+
+ try {
+ if (jmsMsg instanceof TextMessage) {
+ String xmlPayload = ((TextMessage) jmsMsg).getText();
+
+ if (xmlPayload != null) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xmlPayload));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ rootElement = builder.getDocumentElement();
+ operationFromPayload = rootElement.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) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ rootElement = builder.getDocumentElement();
+ operationFromPayload = rootElement.getLocalName();
+ for (Operation op : serviceOperations) {
+ if (op.getName().equals(operationFromPayload)) {
+ operation = op;
+ break;
+ }
+ }
+ }
+ }
+
+ } catch (XMLStreamException 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("Can't find operation " + (operationName != null ? operationName : ON_MESSAGE_METHOD_NAME));
+ }
+
+ return operation;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java
new file mode 100644
index 0000000000..d864543ac6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.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.operationselector.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class OperationSelectorJMSDefaultServiceProvider implements OperationSelectorProvider {
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private Binding binding;
+
+ public OperationSelectorJMSDefaultServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
+ super();
+ this.component = component;
+ this.service = service;
+ this.binding = binding;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new OperationSelectorJMSDefaultServiceInterceptor((JMSBinding)binding,
+ null,
+ service.getRuntimeWire(binding));
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java
new file mode 100644
index 0000000000..a71c5d8e5e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.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.operationselector.jmsuserprop.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class OperationSelectorJMSUserPropProviderFactory implements OperationSelectorProviderFactory<OperationSelectorJMSUserProp> {
+ private ExtensionPointRegistry registry;
+
+ public OperationSelectorJMSUserPropProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return null;
+ }
+
+ /**
+ */
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new OperationSelectorJMSUserPropServiceProvider(component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java
new file mode 100644
index 0000000000..7886c2d138
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.RuntimeWire;
+
+/**
+ * Interceptor for user property based operation selection
+ *
+ * <operationSelector.jmsUser propertName="MyHeaderProperty"/>
+ *
+ */
+public class OperationSelectorJMSUserPropServiceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSBinding jmsBinding;
+ private OperationSelectorJMSUserProp operationSelector;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+
+ public OperationSelectorJMSUserPropServiceInterceptor(JMSBinding jmsBinding, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.operationSelector = (OperationSelectorJMSUserProp)jmsBinding.getOperationSelector();
+ this.runtimeWire = runtimeWire;
+ this.service = (RuntimeComponentService) runtimeWire.getEndpoint().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java
new file mode 100644
index 0000000000..850a3035ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.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.operationselector.jmsuserprop.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class OperationSelectorJMSUserPropServiceProvider implements OperationSelectorProvider {
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private Binding binding;
+
+ public OperationSelectorJMSUserPropServiceProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
+ super();
+ this.component = component;
+ this.service = service;
+ this.binding = binding;
+ }
+
+ /**
+ */
+ public Interceptor createInterceptor() {
+ return new OperationSelectorJMSUserPropServiceInterceptor((JMSBinding)binding, service.getRuntimeWire(binding));
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_OPERATION_SELECTOR;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/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..d4773c52e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.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.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;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/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..a67c7723e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.0/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/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..e630d0cd53
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.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.policy.authentication.token.provider;
+
+import java.util.List;
+
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationReferencePolicyProvider implements PolicyProvider {
+ private EndpointReference endpointReference;
+
+ public JMSTokenAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ this.endpointReference = endpointReference;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpointReference.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return "component.reference: " + endpointReference.getComponent().getURI()
+ + "#"
+ + endpointReference.getReference().getName()
+ + "("
+ + endpointReference.getBinding().getClass().getName()
+ + ")";
+ }
+
+ /**
+ * @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;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/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..60d0abe6be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.0/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/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..be5ca5dd61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.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.policy.authentication.token.provider;
+
+import java.util.List;
+
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSTokenAuthenticationServicePolicyProvider implements PolicyProvider {
+
+ private Endpoint endpoint;
+
+ public JMSTokenAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ this.endpoint = endpoint;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpoint.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (JMSTokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return "component.service: " + endpoint.getComponent().getURI()
+ + "#"
+ + endpoint.getService().getName()
+ + "("
+ + endpoint.getBinding().getClass().getName()
+ + ")";
+ }
+
+ /**
+ * @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;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.java
new file mode 100644
index 0000000000..8e3055de29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.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.jms.policy.header;
+
+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.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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..030790f51b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.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.policy.header;
+
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.jms.context.JMSBindingContext;
+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.0/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.java
new file mode 100644
index 0000000000..35154e0232
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.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.jms.policy.header;
+
+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.PolicySet;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class JMSHeaderReferencePolicyProvider implements PolicyProvider {
+
+ private EndpointReference endpointReference;
+
+ public JMSHeaderReferencePolicyProvider(EndpointReference endpointReference) {
+ this.endpointReference = endpointReference;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpointReference.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (JMSHeaderPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return "component.reference: " + endpointReference.getComponent().getURI()
+ + "#"
+ + endpointReference.getReference().getName()
+ + "("
+ + endpointReference.getBinding().getClass().getName()
+ + ")";
+ }
+
+ /**
+ * @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;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java
new file mode 100644
index 0000000000..8b665c91a8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 RuntimeException(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java
new file mode 100644
index 0000000000..a263dde29f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.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.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;
+
+/**
+ * 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) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java
new file mode 100644
index 0000000000..17542ace9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java
new file mode 100644
index 0000000000..4b82f2155d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java
@@ -0,0 +1,287 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either 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.ByteArrayInputStream;
+import java.io.StringReader;
+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.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+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.interfacedef.util.FaultException;
+
+/**
+ * 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());
+
+ public DefaultMessageProcessor(JMSBinding jmsBinding) {
+ super(jmsBinding);
+ }
+
+ // 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, OMElement wrapper) {
+ if (msg instanceof TextMessage) {
+ try {
+ String xml = ((TextMessage) msg).getText();
+ Object os;
+ if (xml != null) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ os = builder.getDocumentElement();
+ } else {
+ os = null;
+ }
+
+ if (wrapper != null){
+ //don't modify the original wrapper since it will be reused
+ //clone the wrapper
+ OMElement newWrapper = wrapper.cloneOMElement();
+ if (os != null){
+ newWrapper.addChild((OMNode)os);
+ }
+ return newWrapper;
+ }
+
+ return os;
+
+ } catch (XMLStreamException e) {
+ throw new JMSBindingException(e);
+ } catch (JMSException 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 OMElement) {
+
+ if (unwrap){
+ OMElement firstElement = ((OMElement)o).getFirstElement();
+ if (firstElement == null ) {
+ message.setText(null);
+ } else {
+ message.setText(firstElement.toString());
+ }
+ }else {
+ message.setText(o.toString());
+ }
+ } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof OMElement) {
+ if (unwrap){
+ OMElement firstElement = ((OMElement)((Object[]) o)[0]).getFirstElement();
+ if (firstElement == null ) {
+ message.setText(null);
+ } else {
+ message.setText(firstElement.toString());
+ }
+ }else {
+ message.setText(((Object[]) o)[0].toString());
+ }
+ } else if (o != null) {
+ throw new IllegalStateException("expecting OMElement 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(String.valueOf(((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, OMElement 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)) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ os = builder.getDocumentElement();
+ } else {
+ os = null;
+ }
+
+ if (wrapper != null){
+ //don't modify the original wrapper since it will be reused
+ //clone the wrapper
+ OMElement newWrapper = wrapper.cloneOMElement();
+ if (os != null){
+ newWrapper.addChild((OMNode)os);
+ }
+ return newWrapper;
+ }
+
+ return os;
+
+ } catch (XMLStreamException e) {
+ throw new JMSBindingException(e);
+ } catch (JMSException 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 OMElement) {
+ if (unwrap) {
+ OMElement firstElement = ((OMElement)o).getFirstElement();
+ if (firstElement == null ) {
+ //do nothing, the message will just be set with a byte[0]
+ } else {
+ message.writeBytes(firstElement.toString().getBytes());
+ }
+
+ } else {
+ message.writeBytes(o.toString().getBytes());
+ }
+
+ } else if ((o instanceof Object[]) && ((Object[]) o)[0] instanceof OMElement) {
+ if (unwrap){
+ OMElement firstElement = ((OMElement)((Object[]) o)[0]).getFirstElement();
+ if (firstElement == null ) {
+ //do nothing, the message will just be set with a byte[0]
+ } else {
+ message.writeBytes(firstElement.toString().getBytes());
+ }
+
+ }else {
+ message.writeBytes(((Object[]) o)[0].toString().getBytes());
+ }
+ } else if (o != null) {
+ throw new IllegalStateException("expecting OMElement 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();
+ message.writeBytes(String.valueOf(((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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java
new file mode 100644
index 0000000000..1755a1e2ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.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.jms.provider;
+
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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(EndpointReference endpointReference) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)endpointReference.getBinding());
+ return new JMSBindingReferenceBindingProvider((RuntimeComponent)endpointReference.getComponent(), (RuntimeComponentReference) endpointReference.getReference(), (JMSBinding)endpointReference.getBinding(), extensionPoints, jmsRF);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ JMSBinding binding = (JMSBinding)endpoint.getBinding();
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory(binding);
+ return new JMSBindingServiceBindingProvider((RuntimeComponent)endpoint.getComponent(), (RuntimeComponentService)endpoint.getService(), binding, binding, serviceListenerFactory, extensionPoints, jmsRF);
+ }
+
+ public Class<JMSBinding> getModelType() {
+ return JMSBinding.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java
new file mode 100644
index 0000000000..69d00f4f85
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.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.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.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB;
+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.RuntimeWire;
+
+/**
+ * Implementation of the JMS reference binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingReferenceBindingProvider implements ReferenceBindingProviderRRB {
+
+ 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(RuntimeComponent component, RuntimeComponentReference reference, JMSBinding binding, ExtensionPointRegistry extensions, JMSResourceFactory jmsResourceFactory) {
+ this.reference = reference;
+ this.jmsBinding = binding;
+ this.extensions = extensions;
+ this.component = component;
+ 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(component, reference, jmsBinding);
+ }
+
+ this.responseWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
+ if (this.responseWireFormatProviderFactory != null){
+ this.responseWireFormatProvider = responseWireFormatProviderFactory.createReferenceWireFormatProvider(component, reference, jmsBinding);
+ }
+
+ // 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(jmsBinding, operation, jmsResourceFactory, reference);
+
+ 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 configureBindingChain(RuntimeWire runtimeWire) {
+
+ InvocationChain bindingChain = runtimeWire.getBindingInvocationChain();
+
+ // add transport interceptor
+ bindingChain.addInterceptor(Phase.REFERENCE_BINDING_TRANSPORT,
+ new TransportReferenceInterceptor(jmsBinding,
+ jmsResourceFactory,
+ runtimeWire) );
+
+ // 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(jmsBinding,
+ jmsResourceFactory,
+ runtimeWire) );
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java
new file mode 100644
index 0000000000..ea565f8a6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.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.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.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.OperationSelectorProvider;
+import org.apache.tuscany.sca.provider.OperationSelectorProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
+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.RuntimeWire;
+
+/**
+ * Implementation of the JMS service binding provider.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JMSBindingServiceBindingProvider implements ServiceBindingProviderRRB, JMSServiceListenerDetails {
+ private static final Logger logger = Logger.getLogger(JMSBindingServiceBindingProvider.class.getName());
+
+ 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(RuntimeComponent component, RuntimeComponentService service, Binding targetBinding, JMSBinding binding, JMSServiceListenerFactory serviceListenerFactory, ExtensionPointRegistry extensionPoints, JMSResourceFactory jmsResourceFactory) {
+ this.component = component;
+ this.service = service;
+ this.jmsBinding = binding;
+ this.serviceListenerFactory = serviceListenerFactory;
+ this.targetBinding = targetBinding;
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ // 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(component, service, jmsBinding);
+ }
+
+ // Get the factories/providers for wire format
+ this.requestWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getRequestWireFormat().getClass());
+ if (this.requestWireFormatProviderFactory != null){
+ this.requestWireFormatProvider = requestWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ }
+
+ this.responseWireFormatProviderFactory =
+ (WireFormatProviderFactory)providerFactories.getProviderFactory(jmsBinding.getResponseWireFormat().getClass());
+ if (this.responseWireFormatProviderFactory != null){
+ this.responseWireFormatProvider = responseWireFormatProviderFactory.createServiceWireFormatProvider(component, service, jmsBinding);
+ }
+
+ // 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) {
+ throw new JMSBindingException("Error starting JMSServiceBinding", e);
+ }
+ }
+
+ public void stop() {
+ try {
+ serviceListener.stop();
+ } catch (Exception e) {
+ throw new JMSBindingException("Error stopping JMSServiceBinding", e);
+ }
+ }
+
+ public String getDestinationName() {
+ return serviceListener.getDestinationName();
+ }
+
+ /*
+ * Adds JMS specific interceptors to the binding chain
+ */
+ public void configureBindingChain(RuntimeWire runtimeWire) {
+
+ InvocationChain bindingChain = runtimeWire.getBindingInvocationChain();
+
+ // add transport interceptor
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_TRANSPORT,
+ new TransportServiceInterceptor(jmsBinding,
+ jmsResourceFactory,
+ runtimeWire) );
+
+ // 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, runtimeWire));
+
+ // add callback destination interceptor after operation selector
+ bindingChain.addInterceptor(Phase.SERVICE_BINDING_WIREFORMAT,
+ new CallbackDestinationInterceptor(runtimeWire));
+
+ // 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java
new file mode 100644
index 0000000000..09fe7310e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.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.provider;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.tuscany.sca.binding.jms.JMSBinding;
+import org.apache.tuscany.sca.binding.jms.JMSBindingException;
+
+/**
+ * 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);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java
new file mode 100644
index 0000000000..348764fe43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java
new file mode 100644
index 0000000000..4fc20c0cb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java
new file mode 100644
index 0000000000..3b008e9b55
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.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.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.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) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java
new file mode 100644
index 0000000000..84938558bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.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.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.DataExchangeSemantics;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Invoker for the JMS binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RRBJMSBindingInvoker implements Invoker, DataExchangeSemantics {
+
+ protected Operation operation;
+ protected String operationName;
+
+ protected JMSBinding jmsBinding;
+ protected JMSResourceFactory jmsResourceFactory;
+ protected Destination bindingRequestDest;
+ protected Destination bindingReplyDest;
+ protected RuntimeComponentReference reference;
+ protected RuntimeWire runtimeWire;
+
+ public RRBJMSBindingInvoker(JMSBinding jmsBinding, Operation operation, JMSResourceFactory jmsResourceFactory, RuntimeComponentReference reference) {
+
+ this.operation = operation;
+ operationName = operation.getName();
+
+ this.jmsBinding = jmsBinding;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.reference = reference;
+ this.runtimeWire = reference.getRuntimeWire(jmsBinding);
+
+ 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
+ if (dest == null) {
+ 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 = runtimeWire.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;
+ }
+
+ public boolean allowsPassByReference() {
+ // JMS always pass by value
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java
new file mode 100644
index 0000000000..3ff49ce0cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.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.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;
+
+/**
+ * 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) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java
new file mode 100644
index 0000000000..612dbf783f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.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.binding.jms.provider;
+
+import java.io.ByteArrayInputStream;
+import java.util.logging.Logger;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+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.interfacedef.util.FaultException;
+
+/**
+ * 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());
+
+ public XMLBytesMessageProcessor(JMSBinding jmsBinding) {
+ super(jmsBinding);
+ }
+
+ @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) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(bytes));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ os = builder.getDocumentElement();
+ } else {
+ os = null;
+ }
+ return os;
+ } catch (XMLStreamException e) {
+ throw new JMSBindingException(e);
+ } catch (JMSException 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 OMElement) {
+ message.writeBytes(o.toString().getBytes());
+ } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof OMElement) {
+ message.writeBytes(((Object[])o)[0].toString().getBytes());
+ } else if (o != null) {
+ throw new IllegalStateException("expecting OMElement 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(String.valueOf(((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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java
new file mode 100644
index 0000000000..bba29ff023
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.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.provider;
+
+import java.io.StringReader;
+import java.util.logging.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+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.interfacedef.util.FaultException;
+
+/**
+ * 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());
+
+ public XMLTextMessageProcessor(JMSBinding jmsBinding) {
+ super(jmsBinding);
+ }
+
+ @Override
+ protected Object extractPayload(Message msg) {
+ try {
+
+ String xml = ((TextMessage)msg).getText();
+ Object os;
+ if (xml != null) {
+ XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(xml));
+ StAXOMBuilder builder = new StAXOMBuilder(reader);
+ os = builder.getDocumentElement();
+ } else {
+ os = null;
+ }
+ return os;
+
+ } catch (XMLStreamException e) {
+ throw new JMSBindingException(e);
+ } catch (JMSException 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 OMElement) {
+ message.setText(o.toString());
+ } else if ((o instanceof Object[]) && ((Object[])o)[0] instanceof OMElement) {
+ message.setText(((Object[])o)[0].toString());
+ } else if (o != null) {
+ throw new IllegalStateException("expecting OMElement 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(String.valueOf(((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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java
new file mode 100644
index 0000000000..fd74ae952a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.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.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.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+
+ public TransportReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java
new file mode 100644
index 0000000000..6bcd969765
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.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.binding.jms.transport;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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.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.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.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TransportServiceInterceptor implements Interceptor {
+ private static final Logger logger = Logger.getLogger(TransportServiceInterceptor.class.getName());
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private RuntimeComponentService service;
+ private String correlationScheme;
+
+
+ public TransportServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(jmsBinding);
+ this.service = (RuntimeComponentService)runtimeWire.getEndpoint().getService();
+ this.correlationScheme = jmsBinding.getCorrelationScheme();
+ }
+
+ 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 = new EndpointReferenceImpl(null);
+// msg.setFrom(from);
+// from.setCallbackEndpoint(new EndpointReferenceImpl("/")); // TODO: whats this for?
+// ReferenceParameters parameters = from.getReferenceParameters();
+
+// String conversationID = requestJMSMsg.getStringProperty(JMSBindingConstants.CONVERSATION_ID_PROPERTY);
+// if (conversationID != null) {
+// parameters.setConversationID(conversationID);
+// }
+
+ return msg;
+// } catch (JMSException e) {
+// throw new JMSBindingException(e);
+// }
+ }
+
+ public Message invokeResponse(Message msg) {
+ try {
+
+ //if operation is oneway, return back.
+ Operation operation = msg.getOperation();
+ if (operation != null && operation.isNonBlocking()) {
+ return msg;
+ }
+
+ JMSBindingContext context = msg.getBindingContext();
+ 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;
+ }
+
+ responseJMSMsg.setJMSDeliveryMode(requestJMSMsg.getJMSDeliveryMode());
+ responseJMSMsg.setJMSPriority(requestJMSMsg.getJMSPriority());
+
+ 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();
+ context.closeJmsResponseSession();
+
+ return msg;
+
+ } catch (JMSException e) {
+ throw new JMSBindingException(e);
+ }
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java
new file mode 100644
index 0000000000..831d1246f8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.RuntimeWire;
+
+public class CallbackDestinationInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeComponentService service;
+
+ public CallbackDestinationInterceptor(RuntimeWire runtimeWire) {
+ super();
+ this.service = (RuntimeComponentService) runtimeWire.getEndpoint().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java
new file mode 100644
index 0000000000..9536de2bfa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.RuntimeWire;
+
+public class OperationPropertiesInterceptor implements Interceptor {
+ private Invoker next;
+ private JMSBinding jmsBinding;
+ private RuntimeComponentService service;
+ private List<Operation> serviceOperations;
+
+ public OperationPropertiesInterceptor(JMSBinding jmsBinding, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.service = (RuntimeComponentService) runtimeWire.getEndpoint().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java
new file mode 100644
index 0000000000..374c6d9f66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.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.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesProviderFactory implements WireFormatProviderFactory<WireFormatJMSBytes> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSBytesProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSBytesReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new WireFormatJMSBytesServiceProvider(registry, component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java
new file mode 100644
index 0000000000..01a58a298e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.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.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.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java
new file mode 100644
index 0000000000..9eb4de8fd9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.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.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding)binding;
+
+ // 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 = reference.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(binding,
+ null,
+ reference.getRuntimeWire(binding));
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java
new file mode 100644
index 0000000000..d5eb858192
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.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.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.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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java
new file mode 100644
index 0000000000..bc752ad22b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.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.wireformat.jmsbytes.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSBytesServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesServiceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding)binding;
+
+ // 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 = service.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((JMSBinding)binding,
+ null,
+ service.getRuntimeWire(binding));
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java
new file mode 100644
index 0000000000..1f28a02328
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.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.jms.wireformat.jmsbytesxml.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+
+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(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSBytesXMLReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding);
+ return new WireFormatJMSBytesXMLServiceProvider(registry, component, service, binding, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java
new file mode 100644
index 0000000000..4839eaf396
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.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.jms.wireformat.jmsbytesxml.runtime;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+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.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.RuntimeWire;
+
+
+public class WireFormatJMSBytesXMLReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesXMLReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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);
+ OMElement om = (OMElement) response;
+ e.setFaultName(new QName(om.getNamespace().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java
new file mode 100644
index 0000000000..5ed107d06c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.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.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.Binding;
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+public class WireFormatJMSBytesXMLReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesXMLReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding)binding;
+
+ // 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(component, reference, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+ }
+
+ 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(binding,
+ null,
+ reference.getRuntimeWire(binding));
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java
new file mode 100644
index 0000000000..f360db13ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.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 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.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.RuntimeWire;
+
+public class WireFormatJMSBytesXMLServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSBytesXMLServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java
new file mode 100644
index 0000000000..db8416c778
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.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.jmsbytesxml.runtime;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.Binding;
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+public class WireFormatJMSBytesXMLServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSBytesXMLServiceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding,
+ JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding)binding;
+ 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(component, service, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+ }
+
+ 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((JMSBinding)binding,
+ jmsResourceFactory,
+ service.getRuntimeWire(binding));
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java
new file mode 100644
index 0000000000..98ca94e407
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.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.wireformat.jmsdefault.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @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(RuntimeComponent component, RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSDefaultReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component, RuntimeComponentService service, Binding binding) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding) binding);
+ return new WireFormatJMSDefaultServiceProvider(registry, component, service, binding, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java
new file mode 100644
index 0000000000..7bdeb9dae8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.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.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.axiom.om.OMElement;
+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.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.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private DefaultMessageProcessor requestMessageProcessor;
+ private DefaultMessageProcessor responseMessageProcessor;
+ private HashMap<String, Boolean> inputWrapperMap;
+ private HashMap<String, OMElement> outputWrapperMap;
+
+ public WireFormatJMSDefaultReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, Boolean> inputWrapperMap,
+ HashMap<String, OMElement> outputWrapperMap) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ 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);
+ this.responseMessageProcessor = new DefaultMessageProcessor(jmsBinding);
+ 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 {
+
+ OMElement 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);
+ OMElement om = (OMElement) response;
+ e.setFaultName(new QName(om.getNamespace().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java
new file mode 100644
index 0000000000..deec71a3f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.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.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+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.assembly.Binding;
+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.core.ExtensionPointRegistry;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+ private HashMap<String, Boolean> inputWrapperMap;
+ private HashMap<String, OMElement> outputWrapperMap;
+
+ public WireFormatJMSDefaultReferenceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentReference reference, Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding) binding;
+
+ this.inputWrapperMap = new HashMap<String, Boolean>();
+ this.outputWrapperMap = new HashMap<String, OMElement>();
+
+ // 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);
+ }
+
+ // 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
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+
+ // 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(component, reference, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ 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();
+ OMNamespace ns = factory.createOMNamespace(namespace, "ns2");
+ OMElement wrapper = factory.createOMElement(opName, ns);
+
+ 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((JMSBinding) binding, null, reference.getRuntimeWire(binding), inputWrapperMap, outputWrapperMap);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java
new file mode 100644
index 0000000000..2043a122ce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.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.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.jms.BytesMessage;
+import javax.jms.Session;
+
+import org.apache.axiom.om.OMElement;
+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.DefaultMessageProcessor;
+import org.apache.tuscany.sca.binding.jms.provider.JMSResourceFactory;
+import org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefault;
+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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private DefaultMessageProcessor requestMessageProcessor;
+ private DefaultMessageProcessor responseMessageProcessor;
+ private HashMap<String,OMElement> inputWrapperMap;
+ private HashMap<String, Boolean> outputWrapperMap;
+
+ public WireFormatJMSDefaultServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, OMElement> inputWrapperMap,
+ HashMap<String, Boolean> outputWrapperMap) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ 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);
+ this.responseMessageProcessor = new DefaultMessageProcessor(jmsBinding);
+ 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
+ OMElement 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);
+ }
+ }
+
+ msg.setBody(responseJMSMsg);
+
+ return msg;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java
new file mode 100644
index 0000000000..68d2f8189d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.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.jms.wireformat.jmsdefault.runtime;
+
+import java.util.HashMap;
+import java.util.List;
+
+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.assembly.Binding;
+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.core.ExtensionPointRegistry;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSDefaultServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+ private HashMap<String, OMElement> inputWrapperMap;
+ private HashMap<String, Boolean> outputWrapperMap;
+
+ public WireFormatJMSDefaultServiceProvider(ExtensionPointRegistry registry, RuntimeComponent component, RuntimeComponentService service, Binding binding, JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding) binding;
+ this.jmsResourceFactory = jmsResourceFactory;
+
+ this.inputWrapperMap = new HashMap<String, OMElement>();
+ 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
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+
+ // 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(component, service, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ 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();
+ OMNamespace ns = factory.createOMNamespace(namespace, "ns1");
+ OMElement wrapper = factory.createOMElement(opName, ns);
+ 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(binding, jmsResourceFactory, service.getRuntimeWire(binding), this.inputWrapperMap, this.outputWrapperMap);
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java
new file mode 100644
index 0000000000..47c6e42ad1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.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.jmsobject.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectProviderFactory implements WireFormatProviderFactory<WireFormatJMSObject> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSObjectProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSObjectReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new WireFormatJMSObjectServiceProvider(registry, component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java
new file mode 100644
index 0000000000..e82a1d8ffe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.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.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.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ private HashMap<String, String> singleArgMap;
+
+ public WireFormatJMSObjectReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap<String, String> hashMap) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java
new file mode 100644
index 0000000000..f0a5a64f02
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.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.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ 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,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding)binding;
+
+ this.singleArgMap = new HashMap<String,String>();
+
+ // 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(binding,
+ null,
+ reference.getRuntimeWire(binding), this.singleArgMap);
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java
new file mode 100644
index 0000000000..af57152d2b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.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.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.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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle;
+
+ public WireFormatJMSObjectServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory,
+ RuntimeWire runtimeWire, HashMap<String, Class<?>> singleArgMap, boolean wrapSingle) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java
new file mode 100644
index 0000000000..fb96d71811
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.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.jms.wireformat.jmsobject.runtime;
+
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSObjectServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+ private HashMap<String,Class<?>> singleArgMap;
+ private boolean wrapSingle = true;
+
+ public WireFormatJMSObjectServiceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding)binding;
+ this.singleArgMap = new HashMap<String,Class<?>>();
+
+ // 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((JMSBinding)binding, null,service.getRuntimeWire(binding),
+ this.singleArgMap, wrapSingle );
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java
new file mode 100644
index 0000000000..76181c6ba1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.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.jmstext.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextProviderFactory implements WireFormatProviderFactory<WireFormatJMSText> {
+ private ExtensionPointRegistry registry;
+
+ public WireFormatJMSTextProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ /**
+ */
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSTextReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return new WireFormatJMSTextServiceProvider(registry, component, service, binding);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java
new file mode 100644
index 0000000000..ec3270b8f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.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.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.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java
new file mode 100644
index 0000000000..cc41b1cc28
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.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.jmstext.runtime;
+
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding)binding;
+
+ // 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 = reference.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(binding,
+ null,
+ reference.getRuntimeWire(binding));
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java
new file mode 100644
index 0000000000..335b4c4cb7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.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.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.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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java
new file mode 100644
index 0000000000..53c4950b6e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.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.wireformat.jmstext.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextServiceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding)binding;
+
+ // 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 = service.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((JMSBinding)binding,
+ null,
+ service.getRuntimeWire(binding));
+ }
+
+ /**
+ */
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java
new file mode 100644
index 0000000000..3fe0e66722
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.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.jmstextxml.runtime;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @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(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return new WireFormatJMSTextXMLReferenceProvider(registry, component, reference, binding);
+ }
+
+ /**
+ */
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ JMSResourceFactory jmsRF = jmsRFEP.createJMSResourceFactory((JMSBinding)binding);
+ return new WireFormatJMSTextXMLServiceProvider(registry, component, service, binding, jmsRF);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class getModelType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java
new file mode 100644
index 0000000000..f83dfb3cd6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.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.binding.jms.wireformat.jmstextxml.runtime;
+
+
+
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+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.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.RuntimeWire;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLReferenceInterceptor implements Interceptor {
+
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+
+ public WireFormatJMSTextXMLReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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);
+ OMElement om = (OMElement) response;
+ e.setFaultName(new QName(om.getNamespace().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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java
new file mode 100644
index 0000000000..e201f15ef3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.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.jms.wireformat.jmstextxml.runtime;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.Binding;
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLReferenceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private JMSBinding binding;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextXMLReferenceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ super();
+ this.registry = registry;
+ this.component = component;
+ this.reference = reference;
+ this.binding = (JMSBinding)binding;
+
+ // 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(component, reference, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+ }
+
+ protected boolean isOnMessage() {
+ InterfaceContract ic = reference.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((JMSBinding)binding,
+ null,
+ reference.getRuntimeWire(binding));
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java
new file mode 100644
index 0000000000..551fa9fb69
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.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.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.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.RuntimeWire;
+
+/**
+ * Policy handler to handle PolicySet related to Logging with the QName
+ * {http://tuscany.apache.org/xmlns/sca/1.0/impl/java}LoggingPolicy
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLServiceInterceptor implements Interceptor {
+ private Invoker next;
+ private RuntimeWire runtimeWire;
+ private JMSResourceFactory jmsResourceFactory;
+ private JMSBinding jmsBinding;
+ private JMSMessageProcessor requestMessageProcessor;
+ private JMSMessageProcessor responseMessageProcessor;
+
+ public WireFormatJMSTextXMLServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire) {
+ super();
+ this.jmsBinding = jmsBinding;
+ this.runtimeWire = runtimeWire;
+ this.jmsResourceFactory = jmsResourceFactory;
+ this.requestMessageProcessor = JMSMessageProcessorUtil.getRequestMessageProcessor(jmsBinding);
+ this.responseMessageProcessor = JMSMessageProcessorUtil.getResponseMessageProcessor(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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java
new file mode 100644
index 0000000000..3c1afc6d29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.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.jmstextxml.runtime;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.Binding;
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class WireFormatJMSTextXMLServiceProvider implements WireFormatProvider {
+ private ExtensionPointRegistry registry;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private JMSBinding binding;
+ private JMSResourceFactory jmsResourceFactory;
+ private InterfaceContract interfaceContract;
+
+ public WireFormatJMSTextXMLServiceProvider(ExtensionPointRegistry registry,
+ RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding,
+ JMSResourceFactory jmsResourceFactory) {
+ super();
+ this.component = component;
+ this.service = service;
+ this.binding = (JMSBinding)binding;
+ 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 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(component, service, wsBinding, registry, null);
+ interfaceContract = wsBinding.getBindingInterfaceContract();
+ interfaceContract.getInterface().resetDataBinding(OMElement.class.getName());
+ }
+
+ 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((JMSBinding)binding,
+ jmsResourceFactory,
+ service.getRuntimeWire(binding));
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_BINDING_WIREFORMAT;
+ }
+
+ public InterfaceContract getWireFormatInterfaceContract() {
+ return interfaceContract;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java
new file mode 100644
index 0000000000..625d5b4817
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/client.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/client.composite
new file mode 100644
index 0000000000..dcea428493
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/service.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-jms-runtime/src/test/resources/simple/service.composite
new file mode 100644
index 0000000000..44b7b29610
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..3a9234ed93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/META-INF/MANIFEST.MF
@@ -0,0 +1,64 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JMS Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/pom.xml
new file mode 100644
index 0000000000..1351e57aca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java
new file mode 100644
index 0000000000..c195a16ce5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
new file mode 100644
index 0000000000..8e6684b44d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java
@@ -0,0 +1,974 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either 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.BindingRRB;
+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 BindingRRB, 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 = null;
+ 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 = null;
+ 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;
+
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java
new file mode 100644
index 0000000000..80bc61baa1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = "scaCallbackQueue";
+ String CONVERSATION_ID_PROPERTY = "scaConversationId";
+
+ // XML element and attribute names
+ String HEADERS = "headers";
+
+ int MSG_CTXT_POSITION = 0;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java
new file mode 100644
index 0000000000..74f030ca21
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
new file mode 100644
index 0000000000..be5673bc60
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java
@@ -0,0 +1,1541 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either 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;
+
+
+ private FactoryExtensionPoint modelFactories; // DOB
+ 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;
+ this.modelFactories = modelFactories;
+ }
+
+ /**
+ * 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 = reader.getAttributeValue(null, "initialContextFactory");
+ if (initialContextFactory != null && initialContextFactory.length() > 0) {
+ jmsBinding.setInitialContextFactoryName(initialContextFactory);
+ }
+
+ // Read JNDI URL
+ String jndiURL = reader.getAttributeValue(null, "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 {
+ throw new ContributionReadException("The request wireformat has already been defined. " + "Only one request wire format can be specified.");
+ }
+ } else if (extension instanceof OperationSelector) {
+ if (jmsBinding.getOperationSelector() == null) {
+ jmsBinding.setOperationSelector((OperationSelector) extension);
+ } else {
+ throw new ContributionReadException("More than one operation selector has been specified. " + "Only one operation selector can be specified.");
+ }
+
+ } 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:")) {
+ 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 {
+ error(monitor, "UnknownTokenInURI", jmsBinding, s, uri);
+ return;
+ }
+ }
+ jmsBinding.setDestinationName(uri.substring(4, i));
+ } else {
+ jmsBinding.setDestinationName(uri.substring(4));
+ }
+ }
+
+ public void resolve(JMSBinding model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ Monitor monitor = context.getMonitor();
+ 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));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ 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 = reader.getAttributeValue(null, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setDestinationName(name);
+ }
+
+ String type = reader.getAttributeValue(null, "type");
+ if (type != null && type.length() > 0) {
+ warning(monitor, "DoesntProcessDestinationType", jmsBinding);
+ 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) {
+ jmsBinding.setDestinationCreate(create);
+ }
+
+ jmsBinding.getDestinationProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setConnectionFactoryName(name);
+ } else {
+ error(monitor, "MissingConnectionFactoryName", reader);
+ }
+ jmsBinding.getConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setActivationSpecName(name);
+ } else {
+ warning(monitor, "MissingActivationSpecName", reader);
+ }
+ jmsBinding.getActivationSpecProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseDestination(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "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) {
+ jmsBinding.setResponseDestinationCreate(create);
+ }
+
+ jmsBinding.getResponseDestinationProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseConnectionFactory(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "jndiName");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResponseConnectionFactoryName(name);
+ } else {
+ warning(monitor, "MissingResponseConnectionFactory", reader);
+ }
+ jmsBinding.getResponseConnectionFactoryProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ private void parseResponseActivationSpec(XMLStreamReader reader, JMSBinding jmsBinding, Monitor monitor) throws XMLStreamException {
+ String name = reader.getAttributeValue(null, "name");
+ if (name != null && name.length() > 0) {
+ jmsBinding.setResponseActivationSpecName(name);
+ } else {
+ warning(monitor, "MissingResponseActivationSpec", reader);
+ }
+ jmsBinding.getResponseActivationSpecProperties().putAll(parseBindingProperties(reader, monitor));
+ }
+
+ 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 {
+ throw new ContributionReadException("The response wireformat has already been defined. " + "Only one response wire format can be specified.");
+ }
+ } 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.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 );
+ }
+ }
+
+ // 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.getURI() != null) {
+ writer.writeAttribute("uri", jmsBinding.getURI());
+ }
+
+ //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>
+ */
+ 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>
+ */
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java
new file mode 100644
index 0000000000..a02decd20f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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_TUSCANY_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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java
new file mode 100644
index 0000000000..5c33a3e2c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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_TUSCANY_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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..629160d8fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#binding.jms,model=org.apache.tuscany.sca.binding.jms.JMSBinding
+org.apache.tuscany.sca.binding.jms.wireformat.WireFormatJMSDefaultProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#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://tuscany.apache.org/xmlns/sca/1.1#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.0#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.0#jmsHeader,model=org.apache.tuscany.sca.binding.jms.policy.header.JMSHeaderPolicy
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider
new file mode 100644
index 0000000000..f30da64ca4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider
@@ -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 SCA Definitions Providers
+org.apache.tuscany.sca.binding.jms.policy.JMSBindingDefinitionsProvider
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties
new file mode 100644
index 0000000000..fd43b2c4e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties
new file mode 100644
index 0000000000..9361bb0e3c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/binding-jms-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.
+#
+#
+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:' 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
+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
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
new file mode 100644
index 0000000000..7a82f95da9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml
@@ -0,0 +1,84 @@
+<?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://www.osoa.org/xmlns/sca/1.0"
+ xmlns:sca="http://www.osoa.org/xmlns/sca/1.0">
+
+ <!-- intents not yet enabled -->
+ <!--sca:bindingType type="sca:binding.jms"
+ alwaysProvides="JMS"
+ mayProvide="atLeastOnce atMostOnce ordered conversation" /-->
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for JMS Binding -->
+
+ <sca:intent name="JMS" constrains="sca:binding.jms">
+ <sca:description>
+ Communication through this binding requires JMS
+ </sca:description>
+ </sca:intent>
+
+ <!-- delivery mode -->
+ <intent name="deliveryMode"
+ constrains="sca:binding.jms">
+ <description>
+ This intent is used to indicate the deliver mode
+ of the sent message
+ </description>
+ </intent>
+
+ <intent name="deliveryMode.persistent">
+ <description>
+ Message are sent persistently
+ </description>
+ </intent>
+
+ <intent name="deliveryMode.nonPersistent">
+ <description>
+ Message are sent non-persistently
+ </description>
+ </intent>
+
+ <!-- priority -->
+ <intent name="priority"
+ constrains="sca:binding.jms">
+ <description>
+ This intent is used to indicate the priority of the
+ sent message
+ </description>
+ </intent>
+
+ <intent name="priority.high">
+ <description>
+ Messages are high priority
+ </description>
+ </intent>
+
+ <intent name="priority.medium">
+ <description>
+ Messages are medium priority
+ </description>
+ </intent>
+
+ <intent name="priority.low">
+ <description>
+ Messages are low priority
+ </description>
+ </intent>
+</definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java
new file mode 100644
index 0000000000..dd30d5ee6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" targetNamespace=\"http://binding-jms\" name=\"binding-jms\">"
+ + " <component name=\"HelloWorldComponent\">"
+ + " <implementation.java class=\"services.HelloWorld\"/>"
+ + " <service name=\"HelloWorldService\">"
+ + " <binding.jms uri=\"jms: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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java
new file mode 100644
index 0000000000..468295df36
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..5180427ec6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.0\" 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.0\" 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2d32b8cf27
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JSONP Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/pom.xml
new file mode 100644
index 0000000000..24d4499eaa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>1.2.1</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java
new file mode 100644
index 0000000000..90daedb647
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.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.jsonp.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+
+public class JSONPBindingProviderFactory implements BindingProviderFactory<JSONPBinding> {
+
+ private ServletHost servletHost;
+
+ public JSONPBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (!hosts.isEmpty()) {
+ this.servletHost = hosts.get(0);
+ }
+ }
+
+ public Class<JSONPBinding> getModelType() {
+ return JSONPBinding.class;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpoint) {
+ return new JSONPReferenceBindingProvider(endpoint);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new JSONPServiceBindingProvider(endpoint, servletHost);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java
new file mode 100644
index 0000000000..851f4b53c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.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.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.DataExchangeSemantics;
+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, DataExchangeSemantics {
+
+ 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 responseJSON = invokeHTTPRequest(uri, jsonArgs);
+
+ Object response = jsonToObjects(responseJSON)[0];
+ msg.setBody(response);
+
+ 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();
+ }
+
+ 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 Object[] jsonToObjects(String jsonRequest) throws JsonParseException, JsonMappingException, IOException {
+ Class<?> c = new Object[0].getClass();
+ Object[] args = (Object[])mapper.readValue("[" + jsonRequest +"]", c);
+ return args;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java
new file mode 100644
index 0000000000..0af9582e97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.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.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;
+
+ public JSONPReferenceBindingProvider(EndpointReference endpoint) {
+ this.endpoint = endpoint;
+ }
+ public Invoker createInvoker(Operation operation) {
+ return new JSONPInvoker(operation, endpoint);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java
new file mode 100644
index 0000000000..4257cc72e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.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.jsonp.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+public class JSONPServiceBindingProvider implements ServiceBindingProvider {
+
+ private Endpoint endpoint;
+ private ServletHost servletHost;
+
+ public JSONPServiceBindingProvider(Endpoint endpoint, ServletHost servletHost) {
+ this.endpoint = endpoint;
+ this.servletHost = servletHost;
+ }
+
+ public void start() {
+ ComponentService service = endpoint.getService();
+ RuntimeWire wire = ((RuntimeComponentService)service).getRuntimeWire(endpoint.getBinding());
+ Interface serviceInterface = service.getInterfaceContract().getInterface();
+ for (Operation op : serviceInterface.getOperations()) {
+ JSONPServlet servlet = new JSONPServlet(wire, 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 null;
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java
new file mode 100644
index 0000000000..edacc2d374
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.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.binding.jsonp.runtime;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+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.RuntimeWire;
+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 RuntimeWire wire;
+ protected transient Operation operation;
+ protected transient ObjectMapper mapper;
+
+ public JSONPServlet(RuntimeWire 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 response = invokeService(args);
+ String jsonResponse = getJSONResponse(servletRequest, response);
+ servletResponse.getOutputStream().println(jsonResponse);
+ }
+
+ /**
+ * Turn the request into JSON
+ */
+ 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 + "]";
+ }
+
+ /**
+ * 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
+ */
+ 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;
+ }
+
+ /**
+ * Turn the request JSON into objects
+ */
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..5ee1f167ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/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 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);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..99f2958d0d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.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;
+
+
+public class HelloWorldImpl implements HelloWorldService {
+
+ public String sayHello(String name) {
+ return "Hello " + name;
+ }
+
+ public String sayHello2(String firstName, String lastName) {
+ return "Hello " + firstName + " " + lastName;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..b252eddbed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/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.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ String sayHello(String name);
+
+ String sayHello2(String firstName, String lastName);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java
new file mode 100644
index 0000000000..efec56bbe3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.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 test;
+
+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.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"));
+
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite
new file mode 100644
index 0000000000..d058e4869f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/jquery.html b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp-runtime/src/test/resources/jquery.html
new file mode 100644
index 0000000000..a61cee3155
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f251fabedb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA JSONP Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/pom.xml
new file mode 100644
index 0000000000..92fa6a2d0d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java
new file mode 100644
index 0000000000..8872d78fa6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java
new file mode 100644
index 0000000000..2e8bebef0d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java
new file mode 100644
index 0000000000..1cfbdc3ad7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.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.jsonp.impl;
+
+import javax.xml.namespace.QName;
+
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd
new file mode 100644
index 0000000000..0817fd7969
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1"
+ elementFormDefault="qualified">
+
+ <import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" />
+
+ <element name="binding.jsonp" type="t:JSONPBinding"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..23ecc89c4c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,44 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA JSON-RPC Binding Runtime
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 0
+Bnd-LastModified: 1253941843749
+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.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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/NOTICE
new file mode 100644
index 0000000000..28064e5de1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/pom.xml
new file mode 100644
index 0000000000..2c8e633d22
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/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>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-json</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jabsorb</groupId>
+ <artifactId>jabsorb</artifactId>
+ <version>1.3.1</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java
new file mode 100644
index 0000000000..f3abf82520
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.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.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.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+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, DataExchangeSemantics {
+ 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 {
+
+ JSONObject jsonRequest = null;;
+ String requestId = "1";
+ 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);
+ }
+
+ post = new HttpPost(uri);
+ String req = jsonRequest.toString();
+ StringEntity entity = new StringEntity(req, "application/json; charset\"UTF-8\"");
+ post.setEntity(entity);
+
+ response = httpClient.execute(post);
+
+ if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+ //success
+ JSONObject jsonResponse = null;
+ try {
+
+ jsonResponse = new JSONObject(EntityUtils.toString(response.getEntity()));
+
+ //check requestId
+ if (! jsonResponse.getString("id").equalsIgnoreCase(requestId)) {
+ throw new RuntimeException("Invalid response id:" + requestId );
+ }
+
+ msg.setBody(jsonResponse.get("result"));
+ } 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;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java
new file mode 100644
index 0000000000..4059d5a1f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.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.jsonrpc.provider;
+
+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.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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;
+
+/**
+ * JSON-RPC Provider Factory
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCBindingProviderFactory implements BindingProviderFactory<JSONRPCBinding> {
+
+ private MessageFactory messageFactory;
+ private ServletHost servletHost;
+
+ public JSONRPCBindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ this.servletHost = servletHosts.getServletHosts().get(0);
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ messageFactory = modelFactories.getFactory(MessageFactory.class);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) {
+
+ return new JSONRPCReferenceBindingProvider(endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new JSONRPCServiceBindingProvider(endpoint, messageFactory, servletHost);
+ }
+
+ public Class<JSONRPCBinding> getModelType() {
+ return JSONRPCBinding.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java
new file mode 100644
index 0000000000..d25861b610
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.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.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.DataExchangeSemantics;
+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, DataExchangeSemantics {
+ 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;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java
new file mode 100644
index 0000000000..e5d24f1e1c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.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.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.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) {
+ return new JSONRPCClientInvoker(endpointReference, operation, httpClient);
+ }
+
+ public void start() {
+ // TODO Provide support for JSONRPC References
+ }
+
+ public void stop() {
+ // TODO Provide support for JSONRPC References
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java
new file mode 100644
index 0000000000..dca4965378
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.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.jsonrpc.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding;
+import org.apache.tuscany.sca.databinding.json.JSONDataBinding;
+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;
+
+
+/**
+ * Implementation of the JSONRPC Binding Provider for Services
+ *
+ * @version $Rev$ $Date$
+ */
+public class JSONRPCServiceBindingProvider implements ServiceBindingProvider {
+ private MessageFactory messageFactory;
+
+ private Endpoint 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(Endpoint 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 service.getInterfaceContract();
+ }
+
+ 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().createSelfReference(serviceInterface, service).getService();
+
+ // Create and register a Servlet for this service
+ JSONRPCServiceServlet serviceServlet =
+ new JSONRPCServiceServlet(messageFactory, binding, service, serviceContract, 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java
new file mode 100644
index 0000000000..71d335acc8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.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.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.util.List;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+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.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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 RuntimeComponentService componentService;
+ transient InterfaceContract serviceContract;
+ transient Class<?> serviceInterface;
+
+ public JSONRPCServiceServlet(MessageFactory messageFactory,
+ Binding binding,
+ RuntimeComponentService componentService,
+ InterfaceContract serviceContract,
+ Class<?> serviceInterface,
+ Object serviceInstance) {
+ this.messageFactory = messageFactory;
+ this.binding = binding;
+ this.serviceName = binding.getName();
+ this.componentService = componentService;
+ this.serviceContract = serviceContract;
+ 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);
+ }
+ } finally {
+ HttpSession session = request.getSession(false);
+ if (session != null) {
+ session.removeAttribute("JSONRPCBridge");
+ }
+ }
+ }
+ }
+
+ private void handleServiceRequest(HttpServletRequest request, HttpServletResponse response) throws IOException {
+ // 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");
+ OutputStream out = response.getOutputStream();
+
+ // 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";
+ }
+ BufferedReader in = new BufferedReader(new InputStreamReader(request.getInputStream(), charset));
+
+ // Read the request
+ CharArrayWriter data = new CharArrayWriter();
+ 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;
+ 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
+ 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
+ RuntimeWire wire = componentService.getRuntimeWire(binding, serviceContract);
+ Operation jsonOperation = findOperation(method);
+ Object result = null;
+
+
+ // Invoke the get operation on the service implementation
+ Message requestMessage = messageFactory.createMessage();
+ requestMessage.setOperation(jsonOperation);
+
+ requestMessage.getHeaders().add(request);
+
+ requestMessage.setBody(args);
+
+ //result = wire.invoke(jsonOperation, args);
+ Message responseMessage = null;
+ try {
+ responseMessage = wire.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
+ 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 = serviceContract.getInterface().getOperations();
+ //componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations();
+
+
+ Operation result = null;
+ for (Operation o : operations) {
+ if (o.getName().equalsIgnoreCase(method)) {
+ result = o;
+ break;
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java
new file mode 100644
index 0000000000..4b159fb563
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java
new file mode 100644
index 0000000000..322008de1f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java
new file mode 100644
index 0000000000..bd9d905475
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java
new file mode 100644
index 0000000000..f76ec74b16
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java
new file mode 100644
index 0000000000..08ccb6e6d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java
new file mode 100644
index 0000000000..96dea057e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.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.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();
+ node.destroy();
+ }
+
+ @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\": [ {\"javaClass\": \"java.util.ArrayList\", \"list\": [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.getJSONObject("result").getJSONArray("list").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\": [ {\"javaClass\": \"java.util.HashSet\", \"set\": {\"1\": \"red\", \"2\": \"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.getJSONObject("result").getJSONObject("set").getString("red"));
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java
new file mode 100644
index 0000000000..635c99a462
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.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.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();
+ node.destroy();
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java
new file mode 100644
index 0000000000..0fb748b0d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.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.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();
+ nodeServer.destroy();
+ }
+
+ @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();
+ node.destroy();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java
new file mode 100644
index 0000000000..502b2c2862
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.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 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 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();
+ node.destroy();
+ }
+
+ @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"));
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java
new file mode 100644
index 0000000000..6a13a7d951
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.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.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();
+ node.destroy();
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite
new file mode 100644
index 0000000000..8d7a60b30f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite
new file mode 100644
index 0000000000..0cda58286e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f7714ece88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+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"
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA JSON-RPC Binding Model
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1253941204236
+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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/pom.xml
new file mode 100644
index 0000000000..ad13f641ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java
new file mode 100644
index 0000000000..1e14502d93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java
new file mode 100644
index 0000000000..707a9d7103
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java
new file mode 100644
index 0000000000..1d1bd4ed43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.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.jsonrpc.impl;
+
+import javax.xml.namespace.QName;
+
+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();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..21b3d0f6e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.rmi.provider;version="
+ 1.4"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA RMI Binding Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397324375
+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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/pom.xml
new file mode 100644
index 0000000000..81a07e17e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-rmi</artifactId>
+ <version>2.0-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java
new file mode 100644
index 0000000000..a90362de84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.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.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.DataExchangeSemantics;
+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, DataExchangeSemantics {
+
+ 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);
+ }
+ }
+
+ public boolean allowsPassByReference() {
+ // RMI always pass by value
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java
new file mode 100644
index 0000000000..113577b5ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.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.rmi.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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(EndpointReference endpointReference) {
+
+ return new RMIReferenceBindingProvider(endpointReference, rmiHost);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new RMIServiceBindingProvider(endpoint, rmiHost);
+ }
+
+ public Class<RMIBinding> getModelType() {
+ return RMIBinding.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java
new file mode 100644
index 0000000000..7a87beeb6c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.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.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.RuntimeComponent;
+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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java
new file mode 100644
index 0000000000..c572b4e19b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.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.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.assembly.Endpoint;
+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.RuntimeWire;
+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 RuntimeWire wire;
+ private Remote rmiProxy;
+
+ public RMIServiceBindingProvider(Endpoint endpoint, RMIHost rmiHost) {
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (RMIBinding)endpoint.getBinding();
+ this.rmiHost = rmiHost;
+ }
+
+ public void start() {
+ // URI uri = URI.create(component.getURI() + "/" + binding.getName());
+ // binding.setURI(uri.toString());
+
+ wire = service.getRuntimeWire(binding);
+ Interface serviceInterface = service.getInterfaceContract().getInterface();
+
+ rmiProxy = createRmiService(serviceInterface);
+
+ try {
+
+ rmiHost.registerService(binding.getURI(), rmiProxy);
+
+ } 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 wire.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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java
new file mode 100644
index 0000000000..cbc860ecc6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java
new file mode 100644
index 0000000000..cd7a0fd625
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java
new file mode 100644
index 0000000000..89ea795529
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java
new file mode 100644
index 0000000000..461c176e1e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java
new file mode 100644
index 0000000000..3b705d2c97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java
new file mode 100644
index 0000000000..c62e3a6b8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.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.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();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType
new file mode 100644
index 0000000000..6def6715fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <service name="HelloWorldService">
+ <interface.java interface="helloworld.HelloWorldService"/>
+ </service>
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType
new file mode 100644
index 0000000000..5a68cdde8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" 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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite
new file mode 100644
index 0000000000..06c1c5e9fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7154d14e1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA RMI Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397320062
+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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/pom.xml
new file mode 100644
index 0000000000..929fc723aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java
new file mode 100644
index 0000000000..36354ddc01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java
new file mode 100644
index 0000000000..38445fa838
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java
new file mode 100644
index 0000000000..498d03c60e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.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.rmi.impl;
+
+import javax.xml.namespace.QName;
+
+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;
+ }
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b26b8a0cbd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Axis2-based Default Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397165593
+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.jms;version="1.1.0",
+ javax.xml.namespace,
+ javax.xml.stream;resolution:=optional,
+ org.apache.axiom.om,
+ org.apache.commons.fileupload;version="1.2.0",
+ 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.binding.sca.axis2;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2;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.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.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.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",
+ org.oasisopen.sca.annotation;version="2.0.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.binding.sca.axis2.runtime
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Export-Package: org.apache.tuscany.sca.binding.sca.axis2;version="2.0.0"
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/pom.xml
new file mode 100644
index 0000000000..3e6ded8bc8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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-modules</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-sca-axis2-runtime</artifactId>
+ <name>Apache Tuscany SCA Axis2-based Default Binding Extension</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</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>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java
new file mode 100644
index 0000000000..4e3f6d82e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.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.sca.axis2.impl;
+
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+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.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * The factory for the Axis2 based implementation of the distributed sca binding
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2SCABindingProviderFactory implements BindingProviderFactory<DistributedSCABinding> {
+
+ private ExtensionPointRegistry extensionPoints;
+
+ public Axis2SCABindingProviderFactory(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) {
+ return new Axis2SCAReferenceBindingProvider(endpointReference, extensionPoints);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new Axis2SCAServiceBindingProvider(endpoint, extensionPoints);
+ }
+
+ public Class<DistributedSCABinding> getModelType() {
+ return DistributedSCABinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
new file mode 100644
index 0000000000..77ec50b097
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.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.sca.axis2.impl;
+
+import java.util.logging.Logger;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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.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.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * The reference binding provider for the remote sca binding implementation. Relies on the
+ * binding-ws-axis implementation for sending messages to remote services so this provider
+ * uses the ws-axis provider under the covers.
+ */
+public class Axis2SCAReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private static final Logger logger = Logger.getLogger(Axis2SCAReferenceBindingProvider.class.getName());
+
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private SCABinding binding;
+
+ private ReferenceBindingProvider axisReferenceBindingProvider;
+ private WebServiceBinding wsBinding;
+
+ public Axis2SCAReferenceBindingProvider(EndpointReference endpointReference,
+ ExtensionPointRegistry extensionPoints) {
+
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ DataBindingExtensionPoint dataBindings = extensionPoints.getExtensionPoint(DataBindingExtensionPoint.class);
+
+ this.component = (RuntimeComponent)endpointReference.getComponent();
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+ this.binding = ((DistributedSCABinding)endpointReference.getBinding()).getSCABinding();
+
+ // build a ws binding model
+ wsBinding = modelFactories.getFactory(WebServiceBindingFactory.class).createWebServiceBinding();
+ wsBinding.setName(this.binding.getName());
+
+ // Turn the java interface contract into a WSDL interface contract
+ BindingWSDLGenerator.generateWSDL(component, reference, wsBinding, extensionPoints, null);
+
+ // Set to use the Axiom data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ contract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ // create a copy of the endpoint reference but with the web service binding in
+ EndpointReference epr = null;
+ try {
+ epr = (EndpointReference)endpointReference.clone();
+ } catch (Exception ex){
+ // we know we can clone endpoint references
+ }
+ epr.setBinding(wsBinding);
+
+ // create the real Axis2 reference binding provider
+ ProviderFactoryExtensionPoint providerFactories =
+ extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ BindingProviderFactory providerFactory =
+ (BindingProviderFactory) providerFactories.getProviderFactory(WebServiceBinding.class);
+ axisReferenceBindingProvider = providerFactory.createReferenceBindingProvider(epr);
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return axisReferenceBindingProvider.createInvoker(operation);
+ }
+
+ public SCABinding getSCABinding () {
+ return binding;
+ }
+
+ public void start() {
+ axisReferenceBindingProvider.start();
+ }
+
+ public void stop() {
+ axisReferenceBindingProvider.stop();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java
new file mode 100644
index 0000000000..b6b98b6b5f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.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.sca.axis2.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.URI;
+import java.net.UnknownHostException;
+import java.util.logging.Logger;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABinding;
+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.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletHostExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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 Axis2SCAServiceBindingProvider implements ServiceBindingProvider {
+
+ private static final Logger logger = Logger.getLogger(Axis2SCAServiceBindingProvider.class.getName());
+
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private SCABinding binding;
+
+ private ServiceBindingProvider axisProvider;
+ private WebServiceBinding wsBinding;
+
+ private boolean started = false;
+
+
+ public Axis2SCAServiceBindingProvider(Endpoint endpoint,
+ ExtensionPointRegistry extensionPoints) {
+
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ ServletHost servletHost = servletHosts.getServletHosts().get(0);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class);
+
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = ((DistributedSCABinding)endpoint.getBinding()).getSCABinding();
+
+ // create a ws binding model
+ wsBinding = modelFactories.getFactory(WebServiceBindingFactory.class).createWebServiceBinding();
+ wsBinding.setName(this.binding.getName());
+
+ URI uri = URI.create(binding.getURI());
+ if (!uri.isAbsolute()) {
+ int port = 8085;
+ String host;
+ try {
+ host = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ host = "localhost";
+ logger.warning("unable to determine host address, using localhost");
+ }
+ ServerSocket socket;
+ try {
+ socket = new ServerSocket(0);
+ port = socket.getLocalPort();
+ // host = socket.getInetAddress().getHostAddress();
+ socket.close();
+ } catch (IOException e) {
+ }
+ String bindURI = "http://" + host + ":" + port + binding.getURI();
+
+ // FIXME: We need to pass the full URI to the endpoint registry
+ binding.setURI(bindURI);
+ }
+
+ wsBinding.setURI(this.binding.getURI());
+
+ // Turn the java interface contract into a WSDL interface contract
+ BindingWSDLGenerator.generateWSDL(component, service, wsBinding, extensionPoints, null);
+
+ // Set to use the Axiom data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ contract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ // create a copy of the endpoint but with the web service binding in
+ Endpoint ep = null;
+ try {
+ ep = (Endpoint)endpoint.clone();
+ } catch (Exception ex){
+ // we know we can clone endpoint references
+ }
+ ep.setBinding(wsBinding);
+
+ // create the real Axis2 service provider
+ ProviderFactoryExtensionPoint providerFactories =
+ extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ BindingProviderFactory providerFactory =
+ (BindingProviderFactory) providerFactories.getProviderFactory(WebServiceBinding.class);
+ axisProvider = providerFactory.createServiceBindingProvider(ep);
+
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ if (started) {
+ return;
+ } else {
+ started = true;
+ }
+
+ axisProvider.start();
+ }
+
+ public void stop() {
+ if (!started) {
+ return;
+ } else {
+ started = false;
+ }
+
+ axisProvider.stop();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..4f3bf6e20a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-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.axis2.impl.Axis2SCABindingProviderFactory;model=org.apache.tuscany.sca.assembly.DistributedSCABinding
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java
new file mode 100644
index 0000000000..a0bfe7409e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.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.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.Ignore;
+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/asynchReference");
+ nodeA = NodeFactory.newInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("asynch", "./target/test-classes/asynchService");
+ nodeB = NodeFactory.newInstance().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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java
new file mode 100644
index 0000000000..ad272528d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/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.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;
+
+@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/callbackReference");
+ nodeA = NodeFactory.newInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/callbackService");
+ nodeB = NodeFactory.newInstance().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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java
new file mode 100644
index 0000000000..30919c5cb0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/promotionReference");
+ nodeA = NodeFactory.newInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/promotionService");
+ nodeB = NodeFactory.newInstance().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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java
new file mode 100644
index 0000000000..c65e4ea5c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/simpleReference");
+ nodeA = NodeFactory.newInstance().createNode("HelloWorld.composite", contrib);
+ nodeA.start();
+
+ contrib = new Contribution("service", "./target/test-classes/simpleService");
+ nodeB = NodeFactory.newInstance().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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java
new file mode 100644
index 0000000000..f7ab3dfe98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java
new file mode 100644
index 0000000000..3d25d37708
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java
new file mode 100644
index 0000000000..a469d197d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java
new file mode 100644
index 0000000000..3f5a21fddd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java
new file mode 100644
index 0000000000..49e5232b31
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java
new file mode 100644
index 0000000000..ccc77c142b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java
new file mode 100644
index 0000000000..c2be798d1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..9355aece1f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java
new file mode 100644
index 0000000000..efc47aa94d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java
new file mode 100644
index 0000000000..6ed813ff0a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java
new file mode 100644
index 0000000000..ba70573efb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java
new file mode 100644
index 0000000000..a87d6eb49a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java
new file mode 100644
index 0000000000..3dc0b12b82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java
new file mode 100644
index 0000000000..b15d6dea80
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java
new file mode 100644
index 0000000000..c4347b084a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java
new file mode 100644
index 0000000000..846bff02e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java
new file mode 100644
index 0000000000..d69f442879
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite
new file mode 100644
index 0000000000..385c456ddf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite
new file mode 100644
index 0000000000..bab26454ba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite
new file mode 100644
index 0000000000..f02c77a01e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d7685c6143
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite
new file mode 100644
index 0000000000..e0fae3c988
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..d7685c6143
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite
new file mode 100644
index 0000000000..dece7b0d63
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite
new file mode 100644
index 0000000000..4579442a99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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">
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite
new file mode 100644
index 0000000000..00ac746111
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite
new file mode 100644
index 0000000000..944dd0b625
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite
new file mode 100644
index 0000000000..87945b6692
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite
new file mode 100644
index 0000000000..f94b6d3ba0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..00afc5b7f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-axis2-runtime/src/test/resources/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:HelloWorld"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..159e362c07
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.binding.sca.provider;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Default Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397165593
+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.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.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";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
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/pom.xml
new file mode 100644
index 0000000000..4691d63f8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.java
new file mode 100644
index 0000000000..c4daa7c727
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.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.sca.provider;
+
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+
+/**
+ * The local SCA Binding provider implementation. It is not currently used.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeSCABindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponentReference reference;
+
+ public RuntimeSCABindingProvider(RuntimeComponent component, RuntimeComponentReference reference, SCABinding binding) {
+ this.reference = reference;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return reference.getInterfaceContract();
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return null;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java
new file mode 100644
index 0000000000..110d15a1cf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.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.sca.provider;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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(EndpointReference endpointReference) {
+
+ return new RuntimeSCAReferenceBindingProvider(extensionPoints, endpointReference);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new RuntimeSCAServiceBindingProvider(extensionPoints, endpoint);
+ }
+
+ public Class<SCABinding> getModelType() {
+ return SCABinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
new file mode 100644
index 0000000000..2679b88dd1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.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.binding.sca.provider;
+
+import java.net.URI;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+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.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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 ReferenceBindingProvider {
+
+ private static final Logger logger = Logger.getLogger(RuntimeSCAReferenceBindingProvider.class.getName());
+
+ private EndpointReference endpointReference;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private SCABinding binding;
+ private boolean started = false;
+
+ private BindingProviderFactory<DistributedSCABinding> distributedProviderFactory = null;
+ private ReferenceBindingProvider distributedProvider = null;
+ private SCABindingFactory scaBindingFactory;
+
+ public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
+ EndpointReference endpointReference) {
+ this.endpointReference = endpointReference;
+ this.component = (RuntimeComponent)endpointReference.getComponent();
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+ this.binding = (SCABinding)endpointReference.getBinding();
+ this.scaBindingFactory =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class).getFactory(SCABindingFactory.class);
+
+ // look to see if a distributed SCA binding implementation has
+ // been included on the classpath. This will be needed by the
+ // provider itself to do it's thing
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
+ extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ distributedProviderFactory =
+ (BindingProviderFactory<DistributedSCABinding>)factoryExtensionPoint
+ .getProviderFactory(DistributedSCABinding.class);
+
+ }
+
+ public boolean isTargetRemote() {
+ boolean targetIsRemote = false;
+
+ // The decision is based on the results of the wiring process in the assembly model
+ // and there are three possibilities
+ // 1 - target service is running in a separate node in a separate JVM
+ // 2 - target service is running in a separate node in the same JVM
+ // 3 - target service is running in the same node
+
+ // TODO - EPR - the method needs to be able to indicate the three cases
+
+
+ if (RemoteBindingHelper.isTargetRemote()) {
+ // TODO - EPR - what is this RemoteBindingHelper for?
+ if (reference.getInterfaceContract() != null) {
+ targetIsRemote = reference.getInterfaceContract().getInterface().isRemotable();
+ } else {
+ targetIsRemote = true;
+ }
+ } if ( (endpointReference.isRemote()) &&
+ (endpointReference.getTargetEndpoint().isRemote())){
+ // case 1
+ targetIsRemote = true;
+ } else if (endpointReference.isRemote()) {
+ // case 2
+ targetIsRemote = false;
+ } else {
+ // case 3
+ targetIsRemote = false;
+ }
+ return targetIsRemote;
+ }
+
+ private ReferenceBindingProvider getDistributedProvider() {
+
+ if (isTargetRemote()) {
+ // initialize the remote provider if it hasn't been done already
+ if (distributedProvider == null) {
+ if (reference.getInterfaceContract() != null && !reference.getInterfaceContract().getInterface().isRemotable()) {
+ throw new IllegalStateException("Reference interface not remotable for component: " + component
+ .getName()
+ + " and reference: "
+ + reference.getName());
+ }
+
+ if (distributedProviderFactory == null) {
+ throw new IllegalStateException("No distributed SCA binding available for component: " + component
+ .getName()
+ + " and reference: "
+ + reference.getName());
+ }
+
+ // create the remote provider
+ DistributedSCABinding distributedBinding = scaBindingFactory.createDistributedSCABinding();
+ distributedBinding.setSCABinding(binding);
+
+ // create a copy of the endpoint reference and change the binding
+ EndpointReference epr = null;
+ try {
+ epr = (EndpointReference)endpointReference.clone();
+ } catch (Exception ex) {
+ // we know we can clone endpoint references
+ }
+ epr.setBinding(distributedBinding);
+
+ distributedProvider =
+ distributedProviderFactory.createReferenceBindingProvider(epr);
+ }
+ }
+
+ return distributedProvider;
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ if (isTargetRemote()) {
+ return getDistributedProvider().getBindingInterfaceContract();
+ } else {
+ if (reference.getReference() != null) {
+ return reference.getReference().getInterfaceContract();
+ } else {
+ return reference.getInterfaceContract();
+ }
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ if (isTargetRemote()) {
+ return getDistributedProvider().supportsOneWayInvocation();
+ } else {
+ return false;
+ }
+ }
+
+ private Invoker getInvoker(RuntimeWire wire, Operation operation) {
+ Endpoint target = wire.getEndpoint();
+ if (target != null) {
+ RuntimeComponentService service = (RuntimeComponentService)target.getService();
+ if (service != null) { // not a callback wire
+ SCABinding scaBinding = service.getBinding(SCABinding.class);
+ InvocationChain chain =
+ service.getInvocationChain(scaBinding, wire.getEndpointReference().getInterfaceContract(), operation);
+ return chain == null ? null : new SCABindingInvoker(chain);
+ }
+ }
+ return null;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ if (isTargetRemote()) {
+ return getDistributedProvider().createInvoker(operation);
+ } else {
+ RuntimeWire wire = reference.getRuntimeWire(binding);
+ Invoker invoker = getInvoker(wire, 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;
+ } else {
+ started = true;
+ }
+
+ if (getDistributedProvider() != null) {
+ distributedProvider.start();
+ }
+ }
+
+ public void stop() {
+ if (!started) {
+ return;
+ } else {
+ started = false;
+ }
+
+ if (getDistributedProvider() != null) {
+ distributedProvider.stop();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java
new file mode 100644
index 0000000000..de21974095
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.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.sca.provider;
+
+import java.net.URI;
+
+import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+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.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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 RuntimeComponent component;
+ private RuntimeComponentService service;
+ private SCABinding binding;
+
+
+ private BindingProviderFactory<DistributedSCABinding> distributedProviderFactory;
+ private ServiceBindingProvider distributedProvider;
+ private DistributedSCABinding distributedBinding;
+
+
+ public RuntimeSCAServiceBindingProvider(ExtensionPointRegistry extensionPoints,
+ Endpoint endpoint) {
+ this.component = (RuntimeComponent)endpoint.getComponent();
+ this.service = (RuntimeComponentService)endpoint.getService();
+ this.binding = (SCABinding)endpoint.getBinding();
+
+ // 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()) {
+
+ // look to see if a distributed SCA binding implementation has
+ // been included on the classpath. This will be needed by the
+ // provider itself to do it's thing
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
+ extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ distributedProviderFactory =
+ (BindingProviderFactory<DistributedSCABinding>)factoryExtensionPoint
+ .getProviderFactory(DistributedSCABinding.class);
+
+ if (distributedProviderFactory != null) {
+
+ SCABindingFactory scaBindingFactory =
+ extensionPoints.getExtensionPoint(FactoryExtensionPoint.class).getFactory(SCABindingFactory.class);
+
+ // create a nested provider to handle the remote case
+ distributedBinding = scaBindingFactory.createDistributedSCABinding();
+ distributedBinding.setSCABinding(binding);
+
+ // create a copy of the endpoint and change the binding
+ Endpoint ep = null;
+ try {
+ ep = (Endpoint)endpoint.clone();
+ } catch (Exception ex) {
+ // we know we can clone endpoint
+ }
+ ep.setBinding(distributedBinding);
+
+ distributedProvider =
+ distributedProviderFactory.createServiceBindingProvider(ep);
+ }
+ }
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ if (distributedProvider != null) {
+ return distributedProvider.getBindingInterfaceContract();
+ } else {
+ if (service.getService() != null) {
+ return service.getService().getInterfaceContract();
+ } else {
+ return service.getInterfaceContract();
+ }
+ }
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+ public void start() {
+ if (distributedProvider != null) {
+ distributedProvider.start();
+ }
+ }
+
+ public void stop() {
+ if (distributedProvider != null) {
+ distributedProvider.stop();
+ }
+
+ if (distributedBinding != null) {
+ // reset the binding URI to null so that if the composite containing the component
+ // with the service/binding is restarted the binding will have the correct URI set
+ SCABinding scaBinding = distributedBinding.getSCABinding();
+ try {
+ URI tempURI = new URI(scaBinding.getURI());
+ if (!tempURI.isAbsolute()){
+ scaBinding.setURI(null);
+ }
+ } catch (Exception ex){
+ scaBinding.setURI(null);
+ }
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
new file mode 100644
index 0000000000..4dee1b8601
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.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.sca.provider;
+
+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.DataExchangeSemantics;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SCABindingInvoker implements Interceptor, DataExchangeSemantics {
+ private InvocationChain chain;
+
+ /**
+ * Construct a SCABindingInvoker that delegates to the service invocaiton chain
+ * @param chain
+ */
+ public SCABindingInvoker(InvocationChain chain) {
+ super();
+ this.chain = chain;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
+ */
+ public Invoker getNext() {
+ return chain.getHeadInvoker();
+ }
+
+ /**
+ * @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) {
+ return getNext().invoke(msg);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.DataExchangeSemantics#allowsPassByReference()
+ */
+ public boolean allowsPassByReference() {
+ return false;
+// return chain.allowsPassByReference();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
new file mode 100644
index 0000000000..c00df2ef35
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml
@@ -0,0 +1,26 @@
+<?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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.sca" mayProvide="" alwaysProvides=""/>
+ </sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java
new file mode 100644
index 0000000000..119d66d14d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.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.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());
+ Assert.assertNotNull(factory.createDistributedSCABinding());
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java
new file mode 100644
index 0000000000..be464172ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" ><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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/Calculator.composite
new file mode 100644
index 0000000000..c404b3bcd4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType
new file mode 100644
index 0000000000..85535842be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..992af5dd44
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF
@@ -0,0 +1,59 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.configuration;version="2.0.0";
+ uses:="org.apache.axis2,
+ org.apache.tuscany.sca.runtime,
+ org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.provider,
+ org.apache.tuscany.sca.core,
+ org.apache.axis2.context,
+ org.apache.tuscany.sca.monitor,
+ org.apache.tuscany.sca.policy,
+ javax.xml.namespace,
+ org.apache.axiom.om,
+ org.apache.axis2.description,
+ javax.xml.stream,
+ org.apache.axis2.engine,
+ org.apache.tuscany.sca.contribution.resolver,
+ org.apache.tuscany.sca.policy.util,
+ org.apache.tuscany.sca.contribution.processor,
+ org.oasisopen.sca",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.header;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany Policy Model for Axis2 WS binding
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397340328
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany Policy Model for Axis2 WS binding
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.axiom.om.impl.llom.factory,
+ org.apache.axiom.soap,
+ org.apache.axis2,
+ org.apache.axis2.context,
+ org.apache.axis2.description,
+ org.apache.axis2.engine,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.configuration;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.header;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.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.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.binding.ws.axis2.policy
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/pom.xml
new file mode 100644
index 0000000000..819e693f96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-binding-ws-axis2-policy</artifactId>
+ <name>Apache Tuscany SCA Policy Model for Axis2 WS binding</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-security</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-M4</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.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ <version>1.2.7</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.4.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-adb</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ <scope>test</scope>
+ </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>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java
new file mode 100644
index 0000000000..985f387178
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.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.authentication.token;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2TokenAuthenticationPolicy {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "axis2TokenAuthentication");
+ public static final String AXIS2_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 AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java
new file mode 100644
index 0000000000..0d08d42bc5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.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.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.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;
+
+/**
+ *
+ * Adjusted for 2.0 environment, Mike Edwards, 4th Dec 2008
+ * @version $Rev$ $Date$
+ */
+public class Axis2TokenAuthenticationPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2TokenAuthenticationPolicy> {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public QName getArtifactType() {
+ return Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_POLICY_QNAME;
+ }
+
+ public Axis2TokenAuthenticationPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public Axis2TokenAuthenticationPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Axis2TokenAuthenticationPolicy policy = new Axis2TokenAuthenticationPolicy();
+ 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, Axis2TokenAuthenticationPolicy.AXIS2_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(Axis2TokenAuthenticationPolicy policy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", SCA11_TUSCANY_NS);
+
+ if ( policy.getTokenName() != null ) {
+ writer.writeStartElement(prefix,
+ Axis2TokenAuthenticationPolicy.AXIS2_TOKEN_AUTHENTICATION_TOKEN_NAME,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getTokenName().toString());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<Axis2TokenAuthenticationPolicy> getModelType() {
+ return Axis2TokenAuthenticationPolicy.class;
+ }
+
+ public void resolve(Axis2TokenAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..5cf095a67f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.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.policy.authentication.token;
+
+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 Axis2TokenAuthenticationPolicyProviderFactory implements PolicyProviderFactory<Axis2TokenAuthenticationPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public Axis2TokenAuthenticationPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new Axis2TokenAuthenticationReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new Axis2TokenAuthenticationServicePolicyProvider(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<Axis2TokenAuthenticationPolicy> getModelType() {
+ return Axis2TokenAuthenticationPolicy.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..00f93fed26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.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.axis2.policy.authentication.token;
+
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+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.Phase;
+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 Axis2TokenAuthenticationReferencePolicyInterceptor implements PhasedInterceptor {
+
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2TokenAuthenticationPolicy policy;
+
+ public Axis2TokenAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2TokenAuthenticationPolicy){
+ policy = (Axis2TokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // could call out here to some 3rd party system to get credentials
+
+ if ( policy.getTokenName() != null){
+ // create Axis representation of header
+ Axis2SOAPHeaderString header = new Axis2SOAPHeaderString();
+ header.setHeaderName(policy.getTokenName());
+ header.setHeaderString("SomeWSAuthorizationToken");
+
+ // add header to Tuscany message
+ msg.getHeaders().add(header);
+ }
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_POLICY;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..cb2f004070
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.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.ws.axis2.policy.authentication.token;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2TokenAuthenticationReferencePolicyProvider implements PolicyProvider {
+ private EndpointReference endpointReference;
+
+ public Axis2TokenAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ super();
+ this.endpointReference = endpointReference;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpointReference.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpointReference.getURI();
+ }
+
+ /**
+ * @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 Axis2TokenAuthenticationReferencePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..c772702526
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.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.ws.axis2.policy.authentication.token;
+
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+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.Phase;
+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 Axis2TokenAuthenticationServicePolicyInterceptor implements PhasedInterceptor {
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2TokenAuthenticationPolicy policy;
+
+ public Axis2TokenAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2TokenAuthenticationPolicy){
+ policy = (Axis2TokenAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ Axis2SOAPHeaderString header = (Axis2SOAPHeaderString)Axis2HeaderPolicyUtil.getHeader(msg, policy.getTokenName());
+
+ if (header != null) {
+
+ // call out here to some 3rd party system to do whatever you
+ // need to turn header credentials into an authenticated principal
+
+ Subject subject = SecurityUtil.getSubject(msg);
+ Principal principal = new TokenPrincipal(header.getHeaderString());
+ 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_POLICY;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..9bfa1b8804
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.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.ws.axis2.policy.authentication.token;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2TokenAuthenticationServicePolicyProvider implements PolicyProvider {
+ private Endpoint endpoint;
+
+ public Axis2TokenAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpoint.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpoint.getURI();
+ }
+
+ /**
+ * @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 Axis2TokenAuthenticationServicePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java
new file mode 100644
index 0000000000..ded09392ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java
new file mode 100644
index 0000000000..dfedaf97a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.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.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.policy.PolicySet;
+
+
+/**
+ * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2ConfigParamPolicyHandler {
+ private PolicySet applicablePolicySet = null;
+
+ public void setUp(Object... context) {
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ Parameter configParam = null;
+ for ( Object contextObject : context ) {
+ if ( contextObject instanceof ConfigurationContext ) {
+ ConfigurationContext configContext = (ConfigurationContext)contextObject;
+ for ( Object policy : applicablePolicySet.getPolicies() ) {
+ 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 {
+ configContext.getAxisConfiguration().addParameter(configParam);
+ } catch ( AxisFault e ) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void cleanUp(Object... context) {
+ }
+
+ public void beforeInvoke(Object... context) {
+ }
+
+ public void afterInvoke(Object... context) {
+
+ }
+
+ public PolicySet getApplicablePolicySet() {
+ return applicablePolicySet;
+ }
+
+ public void setApplicablePolicySet(PolicySet applicablePolicySet) {
+ this.applicablePolicySet = applicablePolicySet;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java
new file mode 100644
index 0000000000..c13c009edf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java
new file mode 100644
index 0000000000..c224e7615a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.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.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.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @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 null;
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return null;
+ }
+
+ public Class<Axis2ConfigParamPolicy> getModelType() {
+ return Axis2ConfigParamPolicy.class;
+ }
+
+ // FIXME: [rfeng] I think this should be refactored into the binding.ws axis2 code
+ public void setUp(ConfigurationContext configContext, PolicySet ps) {
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ Parameter configParam = null;
+ for (Object policy : ps.getPolicies()) {
+ 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 {
+ configContext.getAxisConfiguration().addParameter(configParam);
+ } catch (AxisFault e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java
new file mode 100644
index 0000000000..f25bd8c0cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.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.header;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderPolicy {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+ public static final QName AXIS2_HEADER_POLICY_QNAME = new QName(SCA11_TUSCANY_NS, "axis2Header");
+ public static final String AXIS2_HEADER_NAME = "headerName";
+
+ private QName headerName;
+
+ public QName getHeaderName() {
+ return headerName;
+ }
+
+ public void setHeaderName(QName headerName) {
+ this.headerName = headerName;
+ }
+
+ public QName getSchemaName() {
+ return AXIS2_HEADER_POLICY_QNAME;
+ }
+
+ public boolean isUnresolved() {
+ return false;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java
new file mode 100644
index 0000000000..7c163e5db2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.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.axis2.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.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 Axis2HeaderPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<Axis2HeaderPolicy> {
+ private static final String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public QName getArtifactType() {
+ return Axis2HeaderPolicy.AXIS2_HEADER_POLICY_QNAME;
+ }
+
+ public Axis2HeaderPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+
+ public Axis2HeaderPolicy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ Axis2HeaderPolicy policy = new Axis2HeaderPolicy();
+ 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.setHeaderName(getQName(reader, Axis2HeaderPolicy.AXIS2_HEADER_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(Axis2HeaderPolicy policy, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
+ String prefix = "tuscany";
+ writer.writeStartElement(prefix,
+ getArtifactType().getLocalPart(),
+ getArtifactType().getNamespaceURI());
+ writer.writeNamespace("tuscany", SCA11_TUSCANY_NS);
+
+ if ( policy.getHeaderName() != null ) {
+ writer.writeStartElement(prefix,
+ Axis2HeaderPolicy.AXIS2_HEADER_NAME,
+ getArtifactType().getNamespaceURI());
+ writer.writeCharacters(policy.getHeaderName().toString());
+ writer.writeEndElement();
+ }
+
+ writer.writeEndElement();
+ }
+
+ public Class<Axis2HeaderPolicy> getModelType() {
+ return Axis2HeaderPolicy.class;
+ }
+
+ public void resolve(Axis2HeaderPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java
new file mode 100644
index 0000000000..64d816a8e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.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.policy.header;
+
+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 Axis2HeaderPolicyProviderFactory implements PolicyProviderFactory<Axis2HeaderPolicy> {
+ private ExtensionPointRegistry registry;
+
+ public Axis2HeaderPolicyProviderFactory(ExtensionPointRegistry registry) {
+ super();
+ this.registry = registry;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component) {
+ return null;//new TokenAuthenticationImplementationPolicyProvider(component, implementation);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return new Axis2HeaderReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return new Axis2HeaderServicePolicyProvider(endpoint);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.provider.ProviderFactory#getModelType()
+ */
+ public Class<Axis2HeaderPolicy> getModelType() {
+ return Axis2HeaderPolicy.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java
new file mode 100644
index 0000000000..98d011a8fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.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.ws.axis2.policy.header;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.invocation.Message;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderPolicyUtil {
+
+ public static Axis2SOAPHeader getHeader(Message msg, QName headerName){
+
+ Axis2SOAPHeader axis2Header = null;
+
+ for (Object header : msg.getHeaders()){
+ if (header instanceof Axis2SOAPHeader){
+ Axis2SOAPHeader tmpHeader = (Axis2SOAPHeader)header;
+
+ if (tmpHeader.getHeaderName().equals(headerName)){
+ axis2Header = tmpHeader;
+ break;
+ }
+ }
+ }
+
+ return axis2Header;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..9c2418a44f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.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.ws.axis2.policy.header;
+
+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.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderReferencePolicyInterceptor implements PhasedInterceptor {
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2HeaderPolicy policy;
+
+ public Axis2HeaderReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2HeaderPolicy){
+ policy = (Axis2HeaderPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // TODO - not yet implemented
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_POLICY;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java
new file mode 100644
index 0000000000..9037f3d9de
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.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.ws.axis2.policy.header;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderReferencePolicyProvider implements PolicyProvider {
+ private EndpointReference endpointReference;
+
+ public Axis2HeaderReferencePolicyProvider(EndpointReference endpointReference) {
+ super();
+ this.endpointReference = endpointReference;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpointReference.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2HeaderPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpointReference.getURI();
+ }
+
+ /**
+ * @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 Axis2HeaderReferencePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java
new file mode 100644
index 0000000000..a05f04ad01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.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.ws.axis2.policy.header;
+
+
+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.Phase;
+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 Axis2HeaderServicePolicyInterceptor implements PhasedInterceptor {
+ private Invoker next;
+ private Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private Axis2HeaderPolicy policy;
+
+ public Axis2HeaderServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof Axis2HeaderPolicy){
+ policy = (Axis2HeaderPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+ // TODO - not yet implemented
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_POLICY;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java
new file mode 100644
index 0000000000..88c77711eb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.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.ws.axis2.policy.header;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Axis2HeaderServicePolicyProvider implements PolicyProvider {
+ private Endpoint endpoint;
+
+ public Axis2HeaderServicePolicyProvider(Endpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpoint.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (Axis2HeaderPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpoint.getURI();
+ }
+
+ /**
+ * @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 Axis2HeaderServicePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java
new file mode 100644
index 0000000000..36916f4ff5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.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.axis2.policy.header;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPFactory;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2SOAPHeader {
+
+ private QName headerName;
+
+ public QName getHeaderName() {
+ return headerName;
+ }
+
+ public void setHeaderName(QName headerName) {
+ this.headerName = headerName;
+ }
+
+ public OMElement getAsSOAPHeaderBlock(OMFactory factory) {
+ OMNamespace ns1 = factory.createOMNamespace(headerName.getNamespaceURI(),
+ headerName.getPrefix());
+ OMElement header = ((SOAPFactory)factory).createSOAPHeaderBlock(headerName.getLocalPart(),ns1);
+ return header;
+ }
+
+ public void setAsSOAPHeaderBlock(OMElement header) {
+ headerName = header.getQName();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java
new file mode 100644
index 0000000000..c593f07780
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.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.header;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMText;
+
+/**
+ * Implementation for policies that could be injected as parameter
+ * into the axis2config.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2SOAPHeaderString extends Axis2SOAPHeader {
+
+ private String headerString;
+
+ public String getHeaderString() {
+ return headerString;
+ }
+
+ public void setHeaderString(String headerString) {
+ this.headerString = headerString;
+ }
+
+ public OMElement getAsSOAPHeaderBlock(OMFactory factory) {
+ OMElement header = super.getAsSOAPHeaderBlock(factory);
+ OMText headerText = factory.createOMText(header, headerString);
+ header.addChild(headerText);
+ return header;
+ }
+
+ public void setAsSOAPHeaderBlock(OMElement header) {
+ super.setAsSOAPHeaderBlock(header);
+ headerString = header.getText();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..44df88c1e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#wsConfigParam,model=org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#axis2TokenAuthentication,model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.1#axis2Header,model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..c87c49a145
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/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.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy
+org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyProviderFactory;model=org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java
new file mode 100644
index 0000000000..44f98b157c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.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 java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+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;
+
+/**
+ *
+ * Test the reading of ws config params policy.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyReadTestCase extends TestCase {
+
+ public void testPolicyReading() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ StAXArtifactProcessorExtensionPoint staxProcessors = extensionPoints.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ StAXArtifactProcessor<Object> staxProcessor = new ExtensibleStAXArtifactProcessor(staxProcessors, inputFactory, null);
+
+ URL url = getClass().getResource("mock_policies.xml");
+
+ InputStream urlStream = url.openStream();
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(urlStream);
+
+ Axis2ConfigParamPolicy policy = (Axis2ConfigParamPolicy)staxProcessor.read(reader, new ProcessorContext(extensionPoints));
+ assertEquals(policy.getParamElements().size(), 2);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml
new file mode 100644
index 0000000000..cc84a83a47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml
@@ -0,0 +1,36 @@
+<?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:wsConfigParam xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <user>TuscanyWsUser</user>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.IntegrityPWCBHandler</passwordCallbackClass>" +
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+</tuscany:wsConfigParam> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ae68eec237
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/META-INF/MANIFEST.MF
@@ -0,0 +1,158 @@
+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.tuscany.sca.policy.authentication.basic,
+ org.apache.tuscany.sca.policy.security.ws,
+ 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.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: org.apache.tuscany.sca.binding.ws.axis2.engine.config
+ ;version="2.0.0",org.apache.tuscany.sca.binding.ws.axis2.engine.config.
+ modules;version="2.0.0",org.apache.tuscany.sca.binding.ws.axis2.engine.
+ config.services;version="2.0.0",org.apache.tuscany.sca.binding.ws.axis2
+ .policy.authentication.basic;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Axis2-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 Axis2-based WS Binding Extensio
+ n
+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,
+ 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.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.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.binding.ws;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.configuration;version="2.0.0",
+ org.apache.tuscany.sca.binding.ws.axis2.policy.header;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.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.util;version="2.0.0",
+ org.apache.tuscany.sca.policy.xml.ws;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.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/pom.xml
new file mode 100644
index 0000000000..bc9d96dd0d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/pom.xml
@@ -0,0 +1,416 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-binding-ws-axis2</artifactId>
+ <name>Apache Tuscany SCA Axis2-based WS Binding Extension</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>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-wsdlgen</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-axiom</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb-axiom</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2-policy</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-policy-xml-ws</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-kernel</artifactId>
+ <version>1.4.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.4.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.4.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.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.axis2</groupId>
+ <artifactId>axis2-mtompolicy</artifactId>
+ <version>1.4.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.santuario</groupId>
+ <artifactId>xmlsec</artifactId>
+ <version>1.4.2</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.axis2</groupId>
+ <artifactId>mex</artifactId>
+ <version>1.41</version>
+ <classifier>impl</classifier>
+ </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>
+
+<!--
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>1.3.03</version>
+ </dependency>
+-->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-jetty</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java
new file mode 100644
index 0000000000..46c97e7553
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.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.ws.axis2;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+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.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.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingBasicAuthenticationConfigurator;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+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.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
+
+
+/**
+ * Axis2BindingInvoker uses an Axis2 OperationClient to invoke a remote web service
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingInvoker implements Invoker, DataExchangeSemantics {
+ private final static String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1";
+
+ public static final QName QNAME_WSA_FROM =
+ new QName(AddressingConstants.Final.WSA_NAMESPACE, AddressingConstants.WSA_FROM,
+ AddressingConstants.WSA_DEFAULT_PREFIX);
+ 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 Axis2ServiceClient serviceClient;
+ private QName wsdlOperationName;
+ private Options options;
+ private SOAPFactory soapFactory;
+ private WebServiceBinding wsBinding;
+
+ private BasicAuthenticationPolicy basicAuthenticationPolicy = null;
+ private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null;
+ private List<Axis2HeaderPolicy> axis2HeaderPolicies = new ArrayList<Axis2HeaderPolicy>();
+
+ public Axis2BindingInvoker(Axis2ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory,
+ WebServiceBinding wsBinding) {
+ this.serviceClient = serviceClient;
+ this.wsdlOperationName = wsdlOperationName;
+ this.options = options;
+ this.soapFactory = soapFactory;
+ this.wsBinding = wsBinding;
+
+ // find out which policies are active
+ /*
+ if (wsBinding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)wsBinding).getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (BasicAuthenticationPolicy.class.isInstance(p)) {
+ basicAuthenticationPolicy = (BasicAuthenticationPolicy)p;
+ } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p;
+ } else if (Axis2HeaderPolicy.class.isInstance(p)) {
+ axis2HeaderPolicies.add((Axis2HeaderPolicy)p);
+ }else {
+ // etc. check for other types of policy being present
+ }
+ }
+ }
+ }
+ */
+ }
+
+ private static final QName EXCEPTION = new QName("", "Exception");
+
+ public Message invoke(Message msg) {
+ try {
+ Object 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 = createOperationClient(msg);
+
+ // 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);
+
+ /*
+ for ( PolicyHandler policyHandler : policyHandlerList ) {
+ policyHandler.beforeInvoke(msg, requestMC, operationClient);
+ }
+ */
+
+ // set policy specified headers
+ for (Axis2HeaderPolicy policy : axis2HeaderPolicies){
+ Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, policy.getHeaderName());
+ }
+
+ if (basicAuthenticationPolicy != null) {
+ Axis2BindingBasicAuthenticationConfigurator.setOperationOptions(operationClient, msg, basicAuthenticationPolicy);
+ }
+
+ if (axis2TokenAuthenticationPolicy != null) {
+ Axis2BindingHeaderConfigurator.setHeader(requestMC, msg, axis2TokenAuthenticationPolicy.getTokenName());
+ }
+
+ // 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");
+
+ /*
+ for ( PolicyHandler policyHandler : policyHandlerList ) {
+ policyHandler.afterInvoke(msg, responseMC, operationClient);
+ }
+ */
+
+ 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;
+ }
+
+ @SuppressWarnings("deprecation")
+ protected OperationClient createOperationClient(Message msg) throws AxisFault {
+ SOAPEnvelope env = soapFactory.getDefaultEnvelope();
+ Object[] args = (Object[])msg.getBody();
+ if (args != null && args.length > 0) {
+ 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.");
+ }
+ }
+ }
+ 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.getServiceClient().createClient(wsdlOperationName);
+ operationClient.setOptions(options);
+
+ Endpoint callbackEndpoint = msg.getFrom().getCallbackEndpoint();
+
+/* TODO - EPR - not required for OASIS
+ // set callback endpoint and callback ID for WS-Addressing header
+ EndpointReference fromEPR = null;
+ org.apache.tuscany.sca.runtime.EndpointReference callbackEPR = parameters.getCallbackReference();
+ if (callbackEPR != null) {
+ fromEPR = new EndpointReference(callbackEPR.getBinding().getURI());
+ }
+ Object callbackID = parameters.getCallbackID();
+ if (callbackID != null) {
+ if (fromEPR == null) {
+ fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+ }
+ //FIXME: serialize callback ID to XML in case it is not a string
+ fromEPR.addReferenceParameter(CALLBACK_ID_REFPARM_QN, callbackID.toString());
+ }
+
+ // set conversation ID for WS-Addressing header
+ Object conversationId = parameters.getConversationID();
+ if (conversationId != null) {
+ if (fromEPR == null) {
+ fromEPR = new EndpointReference(AddressingConstants.Final.WSA_ANONYMOUS_URL);
+ }
+ //FIXME: serialize conversation ID to XML in case it is not a string
+ fromEPR.addReferenceParameter(CONVERSATION_ID_REFPARM_QN, conversationId.toString());
+ }
+*/
+
+ // add WS-Addressing header
+ //FIXME: is there any way to use the Axis2 addressing support for this?
+ if (callbackEndpoint != null) {
+ EndpointReference fromEPR = new EndpointReference(callbackEndpoint.getURI());
+ SOAPEnvelope sev = requestMC.getEnvelope();
+ SOAPHeader sh = sev.getHeader();
+ OMElement epr =
+ EndpointReferenceHelper.toOM(sev.getOMFactory(),
+ fromEPR,
+ QNAME_WSA_FROM,
+ AddressingConstants.Final.WSA_NAMESPACE);
+ sh.addChild(epr);
+ requestMC.setFrom(fromEPR);
+ }
+
+ // Set any message headers required by policy
+ // Get the header from the tuscany message
+ // If its not already an OM convert it to OM
+ // add it to the envelope header
+
+ // if target endpoint was not specified when this invoker was created,
+ // use dynamically specified target endpoint passed in on this call
+ if (options.getTo() == null) {
+ Endpoint ep = msg.getTo();
+ if (ep != null) {
+ requestMC.setTo(new EndpointReference(ep.getBinding().getURI()));
+ } else {
+ throw new RuntimeException("Unable to determine destination endpoint");
+ }
+ } else {
+ requestMC.setTo(new EndpointReference(options.getTo().getAddress()));
+ }
+
+ // 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;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java
new file mode 100644
index 0000000000..a04e0d54e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.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.ws.axis2;
+
+import java.util.List;
+
+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.core.ExtensionPointRegistry;
+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.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.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Axis2BindingProviderFactory
+ *
+ * @version $Rev$ $Date$
+ */
+
+public class Axis2BindingProviderFactory implements BindingProviderFactory<WebServiceBinding> {
+
+ private FactoryExtensionPoint modelFactories;
+ private ServletHost servletHost;
+ private DataBindingExtensionPoint dataBindings;
+
+ public Axis2BindingProviderFactory(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);
+ }
+
+ public ReferenceBindingProvider createReferenceBindingProvider(EndpointReference endpointReference) {
+ return new Axis2ReferenceBindingProvider(endpointReference, modelFactories, dataBindings);
+ }
+
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint endpoint) {
+ return new Axis2ServiceBindingProvider(endpoint, servletHost, modelFactories, dataBindings);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java
new file mode 100644
index 0000000000..a7dc09ea6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.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.ws.axis2;
+
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * The Helper class that loades the Axis2 configuration from the axis2.xml
+ */
+public class Axis2ConfiguratorHelper {
+
+ /**
+ * We cannot hold this method directly in the {@link TuscanyAxisConfigurator} class as the super class
+ * uses the TCCL to load classes
+ *
+ * @param isRampartRequired
+ * @return
+ */
+ public static ConfigurationContext getAxis2ConfigurationContext(final boolean isRampartRequired) {
+ try {
+ // TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+ // Allow privileged access to read properties. Requires PropertyPermission read in
+ // security policy.
+ ConfigurationContext configContext =
+ AccessController.doPrivileged(new PrivilegedExceptionAction<ConfigurationContext>() {
+ public ConfigurationContext run() throws AxisFault {
+ // The tuscany-binding-ws-axis2 class loader. We contribute the message
+ // receivers in the axis2.xml
+ ClassLoader cl0 = getClass().getClassLoader();
+
+ // The axis2 class loader
+ ClassLoader cl1 = URLBasedAxisConfigurator.class.getClassLoader();
+
+ ClassLoader tccl = ClassLoaderContext.setContextClassLoader(cl0, cl1);
+
+ try {
+ return new TuscanyAxisConfigurator(isRampartRequired).getConfigurationContext();
+ } finally {
+ if (tccl != null) {
+ Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+ }
+ });
+ return configContext;
+ // deployRampartModule();
+ // configureSecurity();
+ } catch (PrivilegedActionException e) {
+ throw new ServiceRuntimeException(e.getException());
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java
new file mode 100644
index 0000000000..abf5f4008d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.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;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.soap.SOAPFactory;
+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.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.invocation.Message;
+
+/**
+ * Axis2OneWayBindingInvoker uses an Axis2 OperationClient to invoke a OneWay remote web service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2OneWayBindingInvoker extends Axis2BindingInvoker {
+
+ public Axis2OneWayBindingInvoker(Axis2ServiceClient serviceClient,
+ QName wsdlOperationName,
+ Options options,
+ SOAPFactory soapFactory,
+ WebServiceBinding wsBinding) {
+
+ super(serviceClient, wsdlOperationName, options, soapFactory, wsBinding);
+ }
+
+ @Override
+ protected Object invokeTarget(Message msg) throws AxisFault {
+ OperationClient operationClient = createOperationClient(msg);
+
+ // 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java
new file mode 100644
index 0000000000..2aabce9937
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.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.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+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.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+public class Axis2ReferenceBindingProvider implements ReferenceBindingProvider {
+
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private WebServiceBinding wsBinding;
+
+ private Axis2ServiceClient axisClient;
+
+ public Axis2ReferenceBindingProvider(EndpointReference endpointReference,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings) {
+
+ MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.class);
+ 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.getWSDLDocument() == 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());
+ }
+
+ axisClient = new Axis2ServiceClient(component, reference, wsBinding, messageFactory);
+ }
+
+ public void start() {
+ axisClient.start();
+ }
+
+ public void stop() {
+ axisClient.stop();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+ public Invoker createInvoker(Operation operation) {
+ return axisClient.createInvoker(operation);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java
new file mode 100644
index 0000000000..b6aac923a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.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.axis2;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+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.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.oasisopen.sca.ServiceRuntimeException;
+
+public class Axis2ServiceBindingProvider implements ServiceBindingProvider {
+
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
+ private WebServiceBinding wsBinding;
+
+ private Axis2ServiceProvider axisProvider;
+
+ public Axis2ServiceBindingProvider(Endpoint endpoint,
+ ServletHost servletHost,
+ FactoryExtensionPoint modelFactories,
+ DataBindingExtensionPoint dataBindings) {
+
+ if (servletHost == null) {
+ throw new ServiceRuntimeException("No Servlet host is avaible for HTTP web services");
+ }
+
+ MessageFactory messageFactory = modelFactories.getFactory(MessageFactory.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.getWSDLDocument() == null) {
+ throw new ServiceRuntimeException("No WSDL document for " + component.getName() + "/" + service.getName());
+ }
+
+ // Set to use the Axiom data binding
+ InterfaceContract contract = wsBinding.getBindingInterfaceContract();
+ contract.getInterface().resetDataBinding(OMElement.class.getName());
+
+ axisProvider = new Axis2ServiceProvider(component, service, wsBinding, servletHost, messageFactory, modelFactories);
+ }
+
+ public void start() {
+ axisProvider.start();
+ }
+
+ public void stop() {
+ axisProvider.stop();
+ }
+
+ public InterfaceContract getBindingInterfaceContract() {
+ return wsBinding.getBindingInterfaceContract();
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
new file mode 100644
index 0000000000..be4e902eaa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java
@@ -0,0 +1,461 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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 static org.apache.tuscany.sca.binding.ws.axis2.Axis2ConfiguratorHelper.getAxis2ConfigurationContext;
+import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.SOAP12_INTENT;
+import static org.apache.tuscany.sca.binding.ws.axis2.AxisPolicyHelper.isIntentRequired;
+
+import java.io.IOException;
+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.List;
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.BindingOperation;
+import javax.wsdl.Definition;
+import javax.wsdl.Import;
+import javax.wsdl.Port;
+import javax.wsdl.extensions.soap.SOAPAddress;
+import javax.wsdl.extensions.soap.SOAPOperation;
+import javax.wsdl.extensions.soap12.SOAP12Address;
+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.EndpointReference;
+import org.apache.axis2.addressing.EndpointReferenceHelper;
+import org.apache.axis2.client.Options;
+import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisEndpoint;
+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.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.AbstractContract;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy;
+import org.apache.tuscany.sca.common.xml.XMLDocumentHelper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.ws.commons.schema.resolver.URIResolver;
+
+public class Axis2ServiceClient {
+
+ private RuntimeComponent component;
+ private AbstractContract contract;
+ private WebServiceBinding wsBinding;
+ private ServiceClient serviceClient;
+
+ public Axis2ServiceClient(RuntimeComponent component,
+ AbstractContract contract,
+ WebServiceBinding wsBinding,
+ MessageFactory messageFactory) {
+
+ this.component = component;
+ this.contract = contract;
+ this.wsBinding = wsBinding;
+ }
+
+ protected void start() {
+ if (serviceClient == null) {
+ this.serviceClient = createServiceClient();
+ }
+ }
+
+ public ServiceClient getServiceClient() {
+ return serviceClient;
+ }
+
+ protected void configurePolicy(ConfigurationContext context, PolicySet ps) throws AxisFault {
+ if (ps == null) {
+ return;
+ }
+ for (Object policy : ps.getPolicies()) {
+ if (policy instanceof Axis2ConfigParamPolicy) {
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
+ for (Map.Entry<String, OMElement> param : axis2ConfigParamPolicy.getParamElements().entrySet()) {
+ Parameter configParam = new Parameter(param.getKey(), param.getValue().getFirstElement());
+ configParam.setParameterElement(param.getValue());
+ context.getAxisConfiguration().addParameter(configParam);
+ }
+ }
+ }
+ }
+
+ /**
+ * Create an Axis2 ServiceClient
+ */
+ protected ServiceClient createServiceClient() {
+ try {
+ final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding);
+ ConfigurationContext configContext =
+ getAxis2ConfigurationContext(isRampartRequired);
+
+ createPolicyHandlers();
+
+ Definition definition = wsBinding.getWSDLDocument();
+ QName serviceQName = wsBinding.getService().getQName();
+ Port port = wsBinding.getPort();
+ if (port == null) {
+ // service has multiple ports, select one port to use
+ 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;
+ }
+ }
+ }
+ }
+ AxisService axisService =
+ 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);
+ }
+
+ return new ServiceClient(configContext, axisService);
+
+ } catch (AxisFault e) {
+ throw new RuntimeException(e); // TODO: better exception
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 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;
+ }
+ }
+ }
+
+ /**
+ * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205
+ * @param definition
+ * @param serviceName
+ * @return
+ */
+ 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;
+ }
+
+ /**
+ * 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;
+ }
+
+ /*
+ private static <T extends ExtensibilityElement> T getExtensibilityElement(List elements, Class<T> type) {
+ for (Object e : elements) {
+ if (type.isInstance(e)) {
+ return type.cast(e);
+ }
+ }
+ return null;
+ }
+ */
+
+ protected 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;
+ }
+ }
+
+ /**
+ * Create and configure an Axis2BindingInvoker for each operation
+ */
+ protected Invoker createInvoker(Operation operation) {
+ Options options = new Options();
+ 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 (requiresSOAP12())
+ return OMAbstractFactory.getSOAP12Factory();
+ else
+ return OMAbstractFactory.getSOAP11Factory();
+
+ }
+ });
+ QName wsdlOperationQName = new QName(operationName);
+ if (requiresMTOM())
+ {
+ options.setProperty(org.apache.axis2.Constants.Configuration.ENABLE_MTOM, org.apache.axis2.Constants.VALUE_TRUE);
+ }
+ Axis2BindingInvoker invoker;
+ if (operation.isNonBlocking()) {
+ invoker = new Axis2OneWayBindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding);
+ } else {
+ invoker = new Axis2BindingInvoker(this, wsdlOperationQName, options, soapFactory, wsBinding);
+ }
+
+ return invoker;
+ }
+
+ private boolean requiresSOAP12() {
+ return isIntentRequired(wsBinding, SOAP12_INTENT);
+ }
+
+ private boolean requiresMTOM() {
+ return isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT);
+ }
+
+ protected EndpointReference getWSATOEPR(WebServiceBinding binding) {
+ EndpointReference epr = getEPR(binding);
+ if (epr == null) {
+ epr = getPortLocationEPR(binding);
+ } else if (epr.getAddress() == null || epr.getAddress().length() < 1) {
+ EndpointReference bindingEPR = getPortLocationEPR(binding);
+ if (bindingEPR != null) {
+ epr.setAddress(bindingEPR.getAddress());
+ }
+ }
+ return epr;
+ }
+
+ protected 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 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;
+ }
+
+ private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException {
+ if (wsBinding instanceof PolicySubject) {
+
+ // code to create policy handlers using the new policy SPI based
+ // on policy providers
+/*
+ List<PolicyProvider> policyProviders = ((RuntimeComponentReference)contract).getPolicyProviders(wsBinding);
+
+ for (PolicyProvider policyProvider : policyProviders){
+ policyHandler = policyProvider.createHandler();
+ if (policyHandler != null) {
+ policyHandlerList.add(policyHandler);
+ }
+ }
+*/
+ }
+ }
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java
new file mode 100644
index 0000000000..795b3b256f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.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 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 {
+
+ protected Operation operation;
+
+ private Axis2ServiceProvider provider;
+
+ public Axis2ServiceInMessageReceiver(Axis2ServiceProvider provider, Operation operation) {
+ this.provider = provider;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInMessageReceiver() {
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = new Object[] {requestOM};
+
+ provider.invokeTarget(operation, args, 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java
new file mode 100644
index 0000000000..2cd176aae0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.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.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.Operation;
+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());
+
+ protected Operation operation;
+
+ private Axis2ServiceProvider provider;
+
+ public Axis2ServiceInOutSyncMessageReceiver(Axis2ServiceProvider provider, Operation operation) {
+ this.provider = provider;
+ this.operation = operation;
+ }
+
+ public Axis2ServiceInOutSyncMessageReceiver() {
+ }
+
+ @Override
+ public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault {
+ try {
+ OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
+ Object[] args = null;
+
+ if (requestOM != null) {
+ args = new Object[] {requestOM};
+ }
+
+ /*
+ for ( PolicyHandler policyHandler : policyHandlerList ) {
+ policyHandler.beforeInvoke(operation, args, inMC);
+ }
+ */
+
+ OMElement responseOM = (OMElement)provider.invokeTarget(operation, args, inMC);
+
+ /*
+ for ( PolicyHandler policyHandler : policyHandlerList ) {
+ policyHandler.afterInvoke(operation, args, inMC, responseOM);
+ }
+ */
+
+ 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) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ throw AxisFault.makeFault(e);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
new file mode 100644
index 0000000000..4f7e308eb5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java
@@ -0,0 +1,817 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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 static org.apache.tuscany.sca.binding.ws.axis2.Axis2ConfiguratorHelper.getAxis2ConfigurationContext;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+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 java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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 org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.Constants.Configuration;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+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.TransportInDescription;
+import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.axis2.description.WSDLToAxisServiceBuilder;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.engine.MessageReceiver;
+import org.apache.axis2.transport.jms.JMSConstants;
+import org.apache.axis2.transport.jms.JMSListener;
+import org.apache.axis2.transport.jms.JMSSender;
+import org.apache.axis2.transport.jms.JMSUtils;
+import org.apache.tuscany.sca.assembly.AbstractContract;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.SCABinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.axis2.Axis2ServiceClient.URIResolverImpl;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.authentication.token.Axis2TokenAuthenticationPolicy;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.configuration.Axis2ConfigParamPolicy;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.configurator.Axis2BindingHeaderConfigurator;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicy;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeaderString;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
+import org.apache.tuscany.sca.host.http.ServletHost;
+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.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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.security.WSSecurityEngineResult;
+import org.apache.ws.security.handler.WSHandlerConstants;
+import org.apache.ws.security.handler.WSHandlerResult;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class Axis2ServiceProvider {
+ public static final String IMPORT_TAG = "import";
+ public static final String INCLUDE_TAG = "include";
+
+ private static final Logger logger = Logger.getLogger(Axis2ServiceProvider.class.getName());
+
+ private RuntimeComponent component;
+ private AbstractContract contract;
+ private WebServiceBinding wsBinding;
+ private ServletHost servletHost;
+ private MessageFactory messageFactory;
+ private FactoryExtensionPoint modelFactories;
+ private RuntimeAssemblyFactory assemblyFactory;
+ private ConfigurationContext configContext;
+ private JMSSender jmsSender;
+ private JMSListener jmsListener;
+ private Map<String, Port> urlMap = new HashMap<String, Port>();
+
+ private BasicAuthenticationPolicy basicAuthenticationPolicy = null;
+ private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null;
+ private List<Axis2HeaderPolicy> axis2HeaderPolicies = new ArrayList<Axis2HeaderPolicy>();
+
+ 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);
+
+ private static final QName TRANSPORT_JMS_QUALIFIED_INTENT =
+ new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "transport.jms");
+ private static final String DEFAULT_QUEUE_CONNECTION_FACTORY = "TuscanyQueueConnectionFactory";
+
+ //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});
+
+ public Axis2ServiceProvider(RuntimeComponent component,
+ AbstractContract contract,
+ WebServiceBinding wsBinding,
+ ServletHost servletHost,
+ MessageFactory messageFactory,
+ final FactoryExtensionPoint modelFactories) {
+
+ this.component = component;
+ this.contract = contract;
+ this.wsBinding = wsBinding;
+ this.servletHost = servletHost;
+ this.messageFactory = messageFactory;
+ this.modelFactories = modelFactories;
+ this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+
+ final boolean isRampartRequired = AxisPolicyHelper.isRampartRequired(wsBinding);
+ configContext = getAxis2ConfigurationContext(isRampartRequired);
+
+ configContext.setContextRoot(servletHost.getContextPath());
+
+ // Enable MTOM if the policy intent is specified.
+ if (AxisPolicyHelper.isIntentRequired(wsBinding, AxisPolicyHelper.MTOM_INTENT)) {
+ configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setLocked(false);
+ configContext.getAxisConfiguration().getParameter(Configuration.ENABLE_MTOM).setValue("true");
+ }
+
+ // Update port addresses with runtime information, and create a
+ // map from endpoint URIs to WSDL ports that eliminates duplicate
+ // ports for the same endpoint.
+ for (Object port : wsBinding.getService().getPorts().values()) {
+ String portAddress = getPortAddress((Port)port);
+ String endpointURI = computeEndpointURI(portAddress, servletHost);
+ setPortAddress((Port)port, endpointURI);
+ urlMap.put(endpointURI, (Port)port);
+ }
+
+ /*
+ // find out which policies are active
+ if (wsBinding instanceof PolicySubject) {
+ List<PolicySet> policySets = ((PolicySubject)wsBinding).getApplicablePolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (BasicAuthenticationPolicy.class.isInstance(p)) {
+ basicAuthenticationPolicy = (BasicAuthenticationPolicy)p;
+ } else if (Axis2TokenAuthenticationPolicy.class.isInstance(p)) {
+ axis2TokenAuthenticationPolicy = (Axis2TokenAuthenticationPolicy)p;
+ } else if (Axis2HeaderPolicy.class.isInstance(p)) {
+ axis2HeaderPolicies.add((Axis2HeaderPolicy)p);
+ } else {
+ // etc. check for other types of policy being present
+ }
+ }
+ }
+ }
+ */
+ }
+
+ 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;
+ }
+
+ 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);
+ }
+ }
+
+ // TODO - EPR - what to do with URI
+ /*
+ private EndpointReference2 createEndpointReference() {
+ FactoryExtensionPoint factories =
+ component.getComponentContext().getExtensionPointRegistry().getExtensionPoint(FactoryExtensionPoint.class);
+ RuntimeAssemblyFactory factory = (RuntimeAssemblyFactory)factories.getFactory(AssemblyFactory.class);
+ return factory.createEndpointReference();
+ }
+ */
+
+ private String computeEndpointURI(String uri, ServletHost servletHost) {
+
+ if (uri == null) {
+ return null;
+ }
+
+ // pull out the binding intents to see what sort of transport is required
+ PolicySet transportJmsPolicySet = AxisPolicyHelper.getPolicySet(wsBinding, TRANSPORT_JMS_QUALIFIED_INTENT);
+ if (transportJmsPolicySet != null) {
+ if (!uri.startsWith("jms:/")) {
+ uri = "jms:" + uri;
+ }
+
+ // construct the rest of the URI based on the policy. All the details are put
+ // into the URI here rather than being place directly into the Axis configuration
+ // as the Axis JMS sender relies on parsing the target URI
+ Axis2ConfigParamPolicy axis2ConfigParamPolicy = null;
+ for (Object policy : transportJmsPolicySet.getPolicies()) {
+ if (policy instanceof Axis2ConfigParamPolicy) {
+ axis2ConfigParamPolicy = (Axis2ConfigParamPolicy)policy;
+ Iterator paramIterator =
+ axis2ConfigParamPolicy.getParamElements().get(DEFAULT_QUEUE_CONNECTION_FACTORY)
+ .getChildElements();
+
+ if (paramIterator.hasNext()) {
+ StringBuffer uriParams = new StringBuffer("?");
+
+ while (paramIterator.hasNext()) {
+ OMElement parameter = (OMElement)paramIterator.next();
+ uriParams.append(parameter.getAttributeValue(new QName("", "name")));
+ uriParams.append("=");
+ uriParams.append(parameter.getText());
+
+ if (paramIterator.hasNext()) {
+ uriParams.append("&");
+ }
+ }
+
+ uri = uri + uriParams;
+ }
+ }
+ }
+ } else {
+ if (!uri.startsWith("jms:")) {
+ uri = servletHost.getURLMapping(uri).toString();
+ }
+ }
+
+ return uri;
+ }
+
+ public void start() {
+
+ try {
+ createPolicyHandlers();
+ for (Map.Entry<String, Port> entry : urlMap.entrySet()) {
+ AxisService axisService = createAxisService(entry.getKey(), entry.getValue());
+ configContext.getAxisConfiguration().addService(axisService);
+ }
+
+ Axis2ServiceServlet servlet = null;
+ for (String endpointURL : urlMap.keySet()) {
+ if (endpointURL.startsWith("http://") || endpointURL.startsWith("https://")
+ || endpointURL.startsWith("/")) {
+ if (servlet == null) {
+ servlet = new Axis2ServiceServlet();
+ servlet.init(configContext);
+ }
+ //[nash] configContext.setContextRoot(endpointURL);
+ servletHost.addServletMapping(endpointURL, servlet);
+ } else if (endpointURL.startsWith("jms")) {
+ logger.log(Level.INFO, "Axis2 JMS URL=" + endpointURL);
+
+ jmsListener = new JMSListener();
+ jmsSender = new JMSSender();
+ ListenerManager listenerManager = configContext.getListenerManager();
+ TransportInDescription trsIn =
+ configContext.getAxisConfiguration().getTransportIn(Constants.TRANSPORT_JMS);
+
+ // get JMS transport parameters from the computed URL
+ 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(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);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void stop() {
+ if (jmsListener != null) {
+ jmsListener.stop();
+ jmsListener.destroy();
+ } else {
+ for (String endpointURL : urlMap.keySet()) {
+ servletHost.removeServletMapping(endpointURL);
+ }
+ }
+
+ servletHost = null;
+
+ if (jmsSender != null)
+ jmsSender.stop();
+
+ try {
+ for (String endpointURL : urlMap.keySet()) {
+ // get the path to the service
+ URI uriPath = new URI(endpointURL);
+ String stringURIPath = uriPath.getPath();
+
+ /* [nash] Need a leading slash for WSDL imports to work with ?wsdl
+ // remove any "/" from the start of the path
+ if (stringURIPath.startsWith("/")) {
+ stringURIPath = stringURIPath.substring(1, stringURIPath.length());
+ }
+ */
+
+ configContext.getAxisConfiguration().removeService(stringURIPath);
+ }
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ } catch (AxisFault e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private AxisService createAxisService(String endpointURL, Port port) throws AxisFault {
+ AxisService axisService;
+ if (wsBinding.getWSDLDocument() != null) {
+ axisService = createWSDLAxisService(endpointURL, port);
+ } else {
+ axisService = createJavaAxisService(endpointURL);
+ }
+ initAxisOperations(axisService);
+ return axisService;
+ }
+
+ /**
+ * Create an AxisService from the interface class from the SCA service interface
+ */
+ protected AxisService createJavaAxisService(String endpointURL) 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;
+ }
+
+ /**
+ * Workaround for https://issues.apache.org/jira/browse/AXIS2-3205
+ * @param definition
+ * @param serviceName
+ * @return
+ */
+ 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;
+ }
+
+ /**
+ * Create an AxisService from the WSDL doc used by ws binding
+ */
+ protected AxisService createWSDLAxisService(String endpointURL, Port port) throws AxisFault {
+
+ Definition definition = wsBinding.getWSDLDocument();
+ 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
+ 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);
+ for (Iterator i = axisService.getEndpoints().values().iterator(); i.hasNext();) {
+ AxisEndpoint ae = (AxisEndpoint)i.next();
+ if (endpointURL.startsWith("jms")) {
+ 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.getWSDLDefinition(), 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;
+ }
+
+ private 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 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 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 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 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);
+ }
+ }
+ }
+ }
+
+ protected void initAxisOperations(AxisService axisService) {
+ for (Iterator<?> i = axisService.getOperations(); i.hasNext();) {
+ AxisOperation axisOp = (AxisOperation)i.next();
+ Operation op = getOperation(axisOp);
+ if (op != null) {
+
+ if (op.isNonBlocking()) {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_ONLY);
+ } else {
+ axisOp.setMessageExchangePattern(WSDL2Constants.MEP_URI_IN_OUT);
+ }
+
+ MessageReceiver msgrec = null;
+ if (op.isNonBlocking()) {
+ msgrec = new Axis2ServiceInMessageReceiver(this, op);
+ } else {
+ msgrec = new Axis2ServiceInOutSyncMessageReceiver(this, op);
+ }
+ axisOp.setMessageReceiver(msgrec);
+ }
+ }
+ }
+
+ protected Operation getOperation(AxisOperation axisOp) {
+ String operationName = axisOp.getName().getLocalPart();
+ Interface iface = wsBinding.getBindingInterfaceContract().getInterface();
+ for (Operation op : iface.getOperations()) {
+ if (op.getName().equalsIgnoreCase(operationName)) {
+ return op;
+ }
+ }
+ return null;
+ }
+
+ // methods for Axis2 message receivers
+
+ public Object invokeTarget(Operation op, Object[] args, MessageContext inMC) throws InvocationTargetException {
+ String callbackAddress = null;
+ String callbackID = null;
+ Object conversationID = null;
+
+ // create a message object and set the args as its body
+ Message msg = messageFactory.createMessage();
+ msg.setBody(args);
+ msg.setOperation(op);
+
+ //FIXME: can we use the Axis2 addressing support for this?
+ SOAPHeader header = inMC.getEnvelope().getHeader();
+ if (header != null) {
+ OMElement from = header.getFirstChildWithName(QNAME_WSA_FROM);
+ if (from != null) {
+ OMElement callbackAddrElement = from.getFirstChildWithName(QNAME_WSA_ADDRESS);
+ if (callbackAddrElement != null) {
+ if (contract.getInterfaceContract().getCallbackInterface() != null) {
+ callbackAddress = callbackAddrElement.getText();
+ }
+ }
+
+/* TODO - EPR - not required by OASIS
+ OMElement params = from.getFirstChildWithName(QNAME_WSA_REFERENCE_PARAMETERS);
+ if (params != null) {
+ OMElement convIDElement =
+ params.getFirstChildWithName(Axis2BindingInvoker.CONVERSATION_ID_REFPARM_QN);
+ if (convIDElement != null) {
+ if (isConversational()) {
+ conversationID = convIDElement.getText();
+ }
+ }
+ OMElement callbackIDElement =
+ params.getFirstChildWithName(Axis2BindingInvoker.CALLBACK_ID_REFPARM_QN);
+ if (callbackIDElement != null) {
+ callbackID = callbackIDElement.getText();
+ }
+ }
+*/
+ }
+
+ // get policy specified headers
+ for (Axis2HeaderPolicy policy : axis2HeaderPolicies) {
+ //Axis2BindingHeaderConfigurator.getHeader(inMC, msg, policy.getHeaderName());
+ }
+
+ if (axis2TokenAuthenticationPolicy != null) {
+ Axis2SOAPHeaderString tokenHeader = new Axis2SOAPHeaderString();
+ Axis2BindingHeaderConfigurator.getHeader(inMC,
+ msg,
+ axis2TokenAuthenticationPolicy.getTokenName(),
+ tokenHeader);
+ }
+ }
+
+ //fill message with QoS context info
+ fillQoSContext(msg, inMC);
+
+ // Create a from EPR to hold the details of the callback endpoint
+ EndpointReference from = null;
+ if (callbackAddress != null ) {
+ from = assemblyFactory.createEndpointReference();
+ Endpoint fromEndpoint = assemblyFactory.createEndpoint();
+ from.setTargetEndpoint(fromEndpoint);
+ from.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED);
+ msg.setFrom(from);
+ Endpoint callbackEndpoint = assemblyFactory.createEndpoint();
+ callbackEndpoint.setURI(callbackAddress);
+ callbackEndpoint.setUnresolved(true);
+ from.setCallbackEndpoint(callbackEndpoint);
+ }
+
+ /* TODO - EPR - not required in OASIS
+ // set the reference parameters into the "From" EPR
+ if (callbackAddress != null) {
+ parameters.setCallbackReference(createEndpointReference(callbackAddress));
+ }
+ if (callbackID != null) {
+ parameters.setCallbackID(callbackID);
+ }
+ if (conversationID != null) {
+ parameters.setConversationID(conversationID);
+ }
+
+ if (basicAuthenticationPolicy != null) {
+ Axis2BindingBasicAuthenticationConfigurator.parseHTTPHeader(inMC, msg, basicAuthenticationPolicy);
+ }
+ */
+
+ // find the runtime wire and invoke it with the message
+ RuntimeWire wire = ((RuntimeComponentService)contract).getRuntimeWire(getBinding());
+
+ // TODO - EPR - if there is no wire then find the wire for the SCA binding
+ // because this WS endpoint is providing remote support for the
+ // SCA binding
+ if (wire == null){
+ for(RuntimeWire tmpWire : ((RuntimeComponentService)contract).getRuntimeWires()){
+ if (tmpWire.getEndpoint().getBinding() instanceof SCABinding){
+ wire = tmpWire;
+ break;
+ }
+ }
+ }
+ Object response = wire.invoke(op, msg);
+
+ return response;
+ }
+
+ public boolean isConversational() {
+ return wsBinding.getBindingInterfaceContract().getInterface().isConversational();
+ }
+
+ /**
+ * Return the binding for this provider as a primitive binding type
+ * For use when looking up wires registered against the binding.
+ *
+ * @return the binding
+ */
+ protected Binding getBinding() {
+ return wsBinding;
+ }
+
+ private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException {
+ if (wsBinding instanceof PolicySubject) {
+
+ // code to create policy handlers using a policy SPI based
+ // on policy providers
+ /*
+ List<PolicyProvider> policyProviders = ((RuntimeComponentService)contract).getPolicyProviders(wsBinding);
+
+ for (PolicyProvider policyProvider : policyProviders){
+ policyHandler = policyProvider.createHandler();
+ if (policyHandler != null) {
+ policyHandlerList.add(policyHandler);
+ }
+ }
+ */
+ }
+ }
+
+ private void fillQoSContext(Message message, MessageContext axis2MsgCtx) {
+ if (axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS) != null && axis2MsgCtx
+ .getProperty(WSHandlerConstants.RECV_RESULTS) instanceof Vector) {
+ Vector recvResults = (Vector)axis2MsgCtx.getProperty(WSHandlerConstants.RECV_RESULTS);
+ for (int count1 = 0; count1 < recvResults.size(); ++count1) {
+ if (recvResults.elementAt(count1) instanceof WSHandlerResult) {
+ WSHandlerResult wshr = (WSHandlerResult)recvResults.elementAt(count1);
+ Vector results = wshr.getResults();
+ for (int count2 = 0; count2 < results.size(); ++count2) {
+ if (results.elementAt(count2) instanceof WSSecurityEngineResult) {
+ WSSecurityEngineResult securityResult =
+ (WSSecurityEngineResult)wshr.getResults().elementAt(count2);
+ if (securityResult.get("principal") != null) {
+ message.getHeaders().add(securityResult.get("principal"));
+ }
+ }
+ }
+ }
+ }
+
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
new file mode 100644
index 0000000000..debb2c5764
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java
@@ -0,0 +1,356 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.SocketException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.servlet.GenericServlet;
+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.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.http.AxisServlet;
+import org.apache.axis2.transport.http.ListingAgent;
+import org.apache.axis2.transport.http.server.HttpUtils;
+
+/**
+ * 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);
+
+ // A copy of the init method from the base class because we need to replace the
+ // version of the ListenerManager that is used so that we can get it's
+ // shutdown hook removed properly.
+
+ // prevent this method from being called more than once per instance
+ if (initCalled == false) {
+ initCalled = true;
+ // We can't call super.init() as it will just call the AxisServlet version
+ // which we are replacing here. So reflect on the base class and
+ // set the private config field in the base class.
+ //super.init(config);
+ try {
+ Field field = GenericServlet.class.getDeclaredField("config");
+ field.setAccessible(true);
+ field.set(this, config);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+
+ try {
+ this.servletConfig = config;
+ //ServletContext servletContext = servletConfig.getServletContext();
+ this.configContext =
+ (ConfigurationContext) servletContext.getAttribute(CONFIGURATION_CONTEXT);
+ if(configContext == null){
+ configContext = initConfigContext(config);
+ config.getServletContext().setAttribute(CONFIGURATION_CONTEXT, configContext);
+ }
+ axisConfiguration = configContext.getAxisConfiguration();
+
+ ListenerManager listenerManager = new TuscanyListenerManager();
+ listenerManager.init(configContext);
+ TransportInDescription transportInDescription = new TransportInDescription(
+ Constants.TRANSPORT_HTTP);
+ transportInDescription.setReceiver(this);
+ listenerManager.addListener(transportInDescription, true);
+ listenerManager.start();
+ ListenerManager.defaultConfigurationContext = configContext;
+ super.agent = new ListingAgent(configContext);
+
+ initParams();
+
+ } catch (Exception e) {
+ throw new ServletException(e);
+ }
+ }
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java
new file mode 100644
index 0000000000..da02d1033e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.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.ws.axis2;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AxisPolicyHelper {
+
+ public static final String XMLNS_SCA_11 = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ public static final QName AUTHENTICATION_INTENT = new QName(XMLNS_SCA_11, "authentication");
+ public static final QName CONFIDENTIALITY_INTENT = new QName(XMLNS_SCA_11, "confidentiality");
+ public static final QName INTEGRITY_INTENT = new QName(XMLNS_SCA_11, "integrity");
+ public static final QName MTOM_INTENT = new QName(XMLNS_SCA_11, "MTOM");
+ public static final QName SOAP12_INTENT = new QName(XMLNS_SCA_11, "SOAP12");
+
+ 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;
+ }
+
+ public static boolean isRampartRequired(Binding wsBinding) {
+ return isIntentRequired(wsBinding, AUTHENTICATION_INTENT) || isIntentRequired(wsBinding, INTEGRITY_INTENT)
+ || isIntentRequired(wsBinding, CONFIDENTIALITY_INTENT);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java
new file mode 100644
index 0000000000..c8050912d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.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.binding.ws.axis2;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.deployment.DeploymentConstants;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.ModuleBuilder;
+import org.apache.axis2.deployment.URLBasedAxisConfigurator;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.engine.AxisConfigurator;
+import org.apache.axis2.i18n.Messages;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Helps configure Axis2 from a resource in binding.ws.axis2 instead of Axis2.xml
+ * <p/> TODO: Review: should there be a single global Axis ConfigurationContext
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyAxisConfigurator extends URLBasedAxisConfigurator implements AxisConfigurator {
+
+ /* these two fields are part of a temporary fix to solve problems that Maven has with including
+ * rampart-1.4.mar into the classpath and also at the time of Release 1.0 rampart-1.4.mar seems
+ * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded
+ * as a Maven dependency and has been packed with this module
+ */
+ /************start of fix *********************************************************************/
+ private URL axis2_xml =
+ getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml");
+ private URL axis2_repository = null;
+ private URL rampart_mar_url =
+ getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar");
+ /************** end of fix *************************************************************/
+
+ private boolean isRampartRequired;
+
+ public TuscanyAxisConfigurator(boolean isRampartRequired) throws AxisFault {
+ //super(TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"),
+ // TuscanyAxisConfigurator.class.getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart.mar"));
+ super(getResource("/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml"),
+ null);
+ this.isRampartRequired = isRampartRequired;
+ }
+
+ private static URL getResource(final String name) {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run() {
+ return TuscanyAxisConfigurator.class.getResource(name);
+ }
+ });
+ }
+
+ public ConfigurationContext getConfigurationContext() throws AxisFault {
+ if (configContext == null) {
+ configContext = ConfigurationContextFactory.createConfigurationContext(this);
+ }
+ return configContext;
+ }
+
+ private InputStream getResourceAsStream(final String resource) {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run() {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ return cl.getResourceAsStream(resource);
+ }
+ });
+ }
+
+ /* these three methods are part of a temporary fix to solve problems that Maven has with including
+ * rampart-1.3.mar into the classpath and also at the time of Release 1.0 rampart-1.3.mar seems
+ * to pull in a SNAPSHOT version of rampart-project pom. Hence rampart.mar has been excluded
+ * as a Maven dependency and has been packed with this module
+ */
+ /************start of fix *********************************************************************/
+ @Override
+ public AxisConfiguration getAxisConfiguration() throws AxisFault {
+ InputStream axis2xmlStream;
+ try {
+ if (axis2_xml == null) {
+ axis2xmlStream =
+ getResourceAsStream(DeploymentConstants.AXIS2_CONFIGURATION_RESOURCE);
+ } else {
+ axis2xmlStream = axis2_xml.openStream();
+ }
+ axisConfig = populateAxisConfiguration(axis2xmlStream);
+ if (isRampartRequired) {
+ axisConfig.addGlobalModuleRef("rampart");
+ }
+ if (axis2_repository == null) {
+ Parameter axis2repoPara = axisConfig.getParameter(DeploymentConstants.AXIS2_REPO);
+ if (axis2repoPara != null) {
+ String repoValue = (String) axis2repoPara.getValue();
+ if (repoValue != null && !"".equals(repoValue.trim())) {
+ if (repoValue.startsWith("file:/")) {
+ // we treat this case specially , by assuming file is
+ // located in the local machine
+ loadRepository(repoValue);
+ } else {
+ loadRepositoryFromURL(new URL(repoValue));
+ }
+ }
+ } else {
+ //log.info("No repository found , module will be loaded from classpath");
+ try {
+ loadFromClassPath();
+ } catch ( Exception e ) {
+ if (isRampartRequired) {
+ loadRampartModule();
+ }
+ }
+ }
+
+ } else {
+ loadRepositoryFromURL(axis2_repository);
+ }
+
+ } catch (IOException e) {
+ throw new AxisFault(e.getMessage());
+ }
+ axisConfig.setConfigurator(this);
+ return axisConfig;
+ }
+
+ public void loadRampartModule() throws DeploymentException {
+ try {
+ ClassLoader deploymentClassLoader =
+ org.apache.axis2.deployment.util.Utils.createClassLoader(
+ new URL[]{rampart_mar_url},
+ axisConfig.getModuleClassLoader(),
+ true,
+ (File) axisConfig.getParameterValue(Constants.Configuration.ARTIFACTS_TEMP_DIR));
+ final AxisModule module = new AxisModule();
+ module.setModuleClassLoader(deploymentClassLoader);
+ module.setParent(axisConfig);
+ //String moduleFile = fileUrl.substring(0, fileUrl.indexOf(".mar"));
+ if (module.getName() == null) {
+ module.setName("rampart");
+ module.setVersion("1.4");
+ }
+ populateModule(module, rampart_mar_url);
+ module.setFileName(rampart_mar_url);
+ // Allow privileged access to read properties. Requires PropertiesPermission read in
+ // security policy.
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
+ public Object run() throws IOException {
+ addNewModule(module, axisConfig);
+ return null;
+ }
+ });
+ } catch (PrivilegedActionException e) {
+ throw (AxisFault)e.getException();
+ }
+
+ calculateDefaultModuleVersion(axisConfig.getModules(), axisConfig);
+ axisConfig.validateSystemPredefinedPhases();
+ } catch (IOException e) {
+ throw new DeploymentException(e);
+ }
+ }
+ /**
+ * Get the name of the module , where archive name is combination of module name + its version
+ * The format of the name is as follows:
+ * moduleName-00.0000
+ * Example: "addressing-01.0001.mar" would return "addressing"
+ *
+ * @param moduleName the name of the module archive
+ * @return the module name parsed out of the file name
+ */
+ public static String getModuleName(String moduleName) {
+ if (moduleName.endsWith("-SNAPSHOT")) {
+ return moduleName.substring(0, moduleName.indexOf("-SNAPSHOT"));
+ }
+ char delimiter = '-';
+ int version_index = moduleName.lastIndexOf(delimiter);
+ if (version_index > 0) {
+ String versionString = getModuleVersion(moduleName);
+ if (versionString == null) {
+ return moduleName;
+ } else {
+ return moduleName.substring(0, version_index);
+ }
+ } else {
+ return moduleName;
+ }
+ }
+
+ public static String getModuleVersion(String moduleName) {
+ if (moduleName.endsWith("-SNAPSHOT")) {
+ return "SNAPSHOT";
+ }
+ char version_seperator = '-';
+ int version_index = moduleName.lastIndexOf(version_seperator);
+ if (version_index > 0) {
+ String versionString = moduleName.substring(version_index + 1, moduleName.length());
+ try {
+ Float.parseFloat(versionString);
+ return versionString;
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ public static String getModuleName(String moduleName, String moduleVersion) {
+ if (moduleVersion != null && moduleVersion.length() != 0) {
+ moduleName = moduleName + "-" + moduleVersion;
+ }
+ return moduleName;
+ }
+
+ public static boolean isLatest(String moduleVersion, String currentDefaultVersion) {
+ if (AxisModule.VERSION_SNAPSHOT.equals(moduleVersion)) {
+ return true;
+ } else {
+ float m_version = Float.parseFloat(moduleVersion);
+ float m_c_vresion = Float.parseFloat(currentDefaultVersion);
+ return m_version > m_c_vresion;
+ }
+ }
+
+ public static void calculateDefaultModuleVersion(HashMap modules,
+ AxisConfiguration axisConfig) {
+ Iterator allModules = modules.values().iterator();
+ HashMap defaultModules = new HashMap();
+ while (allModules.hasNext()) {
+ AxisModule axisModule = (AxisModule) allModules.next();
+ String moduleName = axisModule.getName();
+ String moduleNameString;
+ String moduleVersionString;
+ if (AxisModule.VERSION_SNAPSHOT.equals(axisModule.getVersion())) {
+ moduleNameString = axisModule.getName();
+ moduleVersionString = axisModule.getVersion();
+ } else {
+ if (axisModule.getVersion() == null) {
+ moduleNameString = getModuleName(moduleName);
+ moduleVersionString = getModuleVersion(moduleName);
+ if (moduleVersionString != null) {
+ try {
+ Float.valueOf(moduleVersionString);
+ axisModule.setVersion(moduleVersionString);
+ axisModule.setName(moduleName);
+ } catch (NumberFormatException e) {
+ moduleVersionString = null;
+ }
+ }
+ } else {
+ moduleNameString = axisModule.getName();
+ moduleVersionString = axisModule.getVersion();
+ }
+ }
+ String currentDefaultVerison = (String) defaultModules.get(moduleNameString);
+ if (currentDefaultVerison != null) {
+ // if the module version is null then , that will be ignore in this case
+ if (!AxisModule.VERSION_SNAPSHOT.equals(currentDefaultVerison)) {
+ if (moduleVersionString != null &&
+ isLatest(moduleVersionString, currentDefaultVerison)) {
+ defaultModules.put(moduleNameString, moduleVersionString);
+ }
+ }
+ } else {
+ defaultModules.put(moduleNameString, moduleVersionString);
+ }
+
+ }
+ Iterator def_mod_itr = defaultModules.keySet().iterator();
+ while (def_mod_itr.hasNext()) {
+ String moduleName = (String) def_mod_itr.next();
+ axisConfig.addDefaultModuleVersion(moduleName, (String) defaultModules.get(moduleName));
+ }
+ }
+
+
+ private void populateModule(AxisModule module, URL moduleUrl) throws DeploymentException {
+ try {
+ ClassLoader classLoader = module.getModuleClassLoader();
+ InputStream moduleStream = classLoader.getResourceAsStream("META-INF/module.xml");
+ if (moduleStream == null) {
+ moduleStream = classLoader.getResourceAsStream("meta-inf/module.xml");
+ }
+ if (moduleStream == null) {
+ throw new DeploymentException(
+ Messages.getMessage(
+ DeploymentErrorMsgs.MODULE_XML_MISSING, moduleUrl.toString()));
+ }
+ ModuleBuilder moduleBuilder = new ModuleBuilder(moduleStream, module, axisConfig);
+ moduleBuilder.populateModule();
+ } catch (IOException e) {
+ throw new DeploymentException(e);
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java
new file mode 100644
index 0000000000..3527061a66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java
new file mode 100644
index 0000000000..eb1e1a27aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.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.ws.axis2;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.engine.ListenerManager;
+import org.apache.axis2.transport.TransportListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A Tuscany specific Axis2 ListenerManager. Created purely as part of
+ * TUSCANY-3149 to unregister the ListenerManager from the runtime
+ * shutown hook
+ */
+public class TuscanyListenerManager extends ListenerManager {
+ private static final Log log = LogFactory.getLog(TuscanyListenerManager.class);
+
+ private ListenerManagerShutdownThread shutdownThread = null;
+
+ /**
+ * To start all the transports
+ */
+ public synchronized void start() {
+
+ ConfigurationContext configctx = getConfigctx();
+
+ // very nasty! but this is in order to get someone running who keeps
+ // getting perm gen errors. This will all go away when we move up to Axis2 1.5
+ HashMap startedTransports = null;
+
+ try {
+ Field field = ListenerManager.class.getDeclaredField("startedTransports");
+ field.setAccessible(true);
+ startedTransports = (HashMap)field.get(this);
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
+
+ for (Iterator transportNames =
+ configctx.getAxisConfiguration().getTransportsIn().values().iterator();
+ transportNames.hasNext();) {
+ try {
+ TransportInDescription transportIn = (TransportInDescription) transportNames.next();
+ TransportListener listener = transportIn.getReceiver();
+ if (listener != null &&
+ startedTransports.get(transportIn.getName()) == null) {
+ listener.init(configctx, transportIn);
+ listener.start();
+ if (startedTransports.get(transportIn.getName()) == null) {
+ startedTransports.put(transportIn.getName(), listener);
+ }
+ }
+ } catch (Exception e) {
+ log.info(e.getMessage(), e);
+ }
+ }
+ shutdownThread = new ListenerManagerShutdownThread(this);
+ Runtime.getRuntime().addShutdownHook(shutdownThread);
+ }
+
+ public synchronized void stop() throws AxisFault {
+ super.stop();
+ try {
+ if (shutdownThread != null) {
+ Runtime.getRuntime().removeShutdownHook(shutdownThread);
+ shutdownThread = null;
+ }
+ } catch (IllegalStateException e) {
+ // Ignore
+ shutdownThread = null;
+ }
+ }
+
+ static class ListenerManagerShutdownThread extends Thread {
+ ListenerManager listenerManager;
+
+ public ListenerManagerShutdownThread(ListenerManager listenerManager) {
+ super();
+ this.listenerManager = listenerManager;
+ }
+
+ public void run() {
+ try {
+ listenerManager.stop();
+ } catch (AxisFault axisFault) {
+ log.error(axisFault.getMessage(), axisFault);
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java
new file mode 100644
index 0000000000..55f1592657
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.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.ws.axis2;
+
+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.axis2.transport.http.server.HttpUtils;
+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 = Axis2ServiceProvider.getPortAddress((Port)p);
+ String modifiedURL = setIPAddress(endpointURL, url);
+ modifiedURL = addContextRoot(modifiedURL, serviceName);
+ Axis2ServiceProvider.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);
+ String ipAddr = HttpUtils.getIpAddress();
+ int requestPort = requestURIObj.getPort();
+ String newAddr = ipAddr + (requestPort != -1 ? ":" + Integer.toString(requestPort) : "");
+ return wsdlURI.replace(wsdlAddr, newAddr);
+ } catch (Exception e) {
+ // URI string not in expected format, so return the WSDL URI unmodified
+ return wsdlURI;
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java
new file mode 100644
index 0000000000..eba7a01798
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.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.axis2.policy.configurator;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+
+import org.apache.axiom.om.util.Base64;
+import org.apache.axis2.client.OperationClient;
+import org.apache.axis2.context.MessageContext;
+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.Message;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy;
+import org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPrincipal;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingBasicAuthenticationConfigurator {
+
+
+ public static void setOperationOptions(OperationClient operationClient, Message msg, BasicAuthenticationPolicy policy) {
+ 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();
+ }
+
+ if (username == null || password == null ){
+ throw new ServiceRuntimeException("Basic authentication username 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);
+ }
+
+ public static void parseHTTPHeader(MessageContext messageContext, Message msg, BasicAuthenticationPolicy policy) {
+
+ 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);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java
new file mode 100644
index 0000000000..647f934c02
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.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.ws.axis2.policy.configurator;
+
+
+
+import javax.xml.namespace.QName;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.context.MessageContext;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2HeaderPolicyUtil;
+import org.apache.tuscany.sca.binding.ws.axis2.policy.header.Axis2SOAPHeader;
+import org.apache.tuscany.sca.invocation.Message;
+
+
+/**
+ * Policy handler to handle PolicySet that contain Axis2ConfigParamPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class Axis2BindingHeaderConfigurator {
+
+
+ public static void setHeader(MessageContext messageContext, Message msg, QName headerQName) {
+
+ if (headerQName != null){
+ SOAPEnvelope envelope = messageContext.getEnvelope();
+ OMFactory factory = envelope.getOMFactory();
+ SOAPHeader soapHeader = envelope.getHeader();
+
+ Axis2SOAPHeader header = Axis2HeaderPolicyUtil.getHeader(msg, headerQName) ;
+
+ if (header != null){
+ soapHeader.addChild(header.getAsSOAPHeaderBlock(factory));
+ }
+ }
+ }
+
+ public static void getHeader(MessageContext messageContext, Message msg, QName headerQName, Axis2SOAPHeader header) {
+
+ SOAPEnvelope sev = messageContext.getEnvelope();
+ SOAPHeader sh = sev.getHeader();
+ OMElement omHeader = sh.getFirstChildWithName(headerQName);
+
+ header.setAsSOAPHeaderBlock(omHeader);
+
+ msg.getHeaders().add(header);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions
new file mode 100644
index 0000000000..090b2550ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory
new file mode 100644
index 0000000000..fba2858221
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/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.ws.axis2.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml
new file mode 100644
index 0000000000..68f0372b61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:bindingType type="sca:binding.ws" mayProvide="SOAP SOAP.V1_1 SOAP.V1_2 MTOM" alwaysProvides=""/>
+
+ <!-- PolicyIntents defined by the SCA Runtime Extension for WS Binding Axis 2 -->
+
+ <!-- see the file sca-policy-1.1-intents-definitions.xml in the -->
+ <!-- assembly-xsd module for spec defined intents -->
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml
new file mode 100644
index 0000000000..ea32836f2a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml
@@ -0,0 +1,504 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT 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 alow 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.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.Axis2ServiceInOutSyncMessageReceiver"/>
+
+ <!-- Added by Tuscany -->
+ <messageReceiver mep="http://www.w3.org/2006/01/wsdl/in-only"
+ class="org.apache.tuscany.sca.binding.ws.axis2.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.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.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list
new file mode 100644
index 0000000000..e6e70dfd4b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list
@@ -0,0 +1 @@
+rampart-1.4.mar \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar
new file mode 100644
index 0000000000..ec870734a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java
new file mode 100644
index 0000000000..2ce23bf2c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.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;
+
+import junit.framework.TestCase;
+
+public class Axis2ReferenceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+// ServiceContract contract = new JavaServiceContract();
+// Operation operation = new Operation<Type>("sayHi", null, null, null, false, null, NO_CONVERSATION);
+// TargetInvoker targetInvoker = axis2Reference.createTargetInvoker(contract, operation);
+// assertNotNull(targetInvoker);
+// assertFalse(targetInvoker instanceof Axis2AsyncTargetInvoker);
+ }
+
+ public void testAsyncTargetInvoker() throws Exception {
+// Axis2ReferenceBinding axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
+// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class
+// Wire inboundWire = EasyMock.createNiceMock(Wire.class);
+// JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+// contract.setCallbackName("");
+// contract.setCallbackClass(GreetingCallback.class);
+// Operation<Type> callbackOp =
+// new Operation<Type>("sayHiCallback", null, null, null, true, null, NO_CONVERSATION);
+// HashMap<String, Operation<Type>> callbackOps = new HashMap<String, Operation<Type>>();
+// callbackOps.put("sayHiCallback", callbackOp);
+// contract.setCallbackOperations(callbackOps);
+// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes();
+// EasyMock.replay(inboundWire);
+//
+// axis2Reference.setWire(inboundWire);
+// Operation operation = new Operation<Type>("sayHi", null, null, null, true, null, NO_CONVERSATION);
+// TargetInvoker asyncTargetInvoker = axis2Reference.createTargetInvoker(contract, operation);
+// assertNotNull(asyncTargetInvoker);
+// assertTrue(asyncTargetInvoker instanceof Axis2AsyncTargetInvoker);
+ }
+
+// @SuppressWarnings("unchecked")
+// private Axis2ReferenceBinding createAxis2Reference(String webAppName, String serviceName) throws Exception {
+// //Create WebServiceBindingDefinition
+// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+// URL url = getClass().getResource(wsdlLocation);
+// assertNotNull("Could not find wsdl " + url.toString(), url);
+//
+// WSDLFactory factory = WSDLFactory.newInstance();
+// WSDLReader reader = factory.newWSDLReader();
+// reader.setFeature("javax.wsdl.verbose", false);
+// InputSource input = new InputSource(url.openStream());
+// Definition wsdlDef = reader.readWSDL(url.toString(), input);
+// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+// "SOAPService"));
+// Port port = wsdlService.getPort("SoapPort");
+// WebServiceBindingDefinition wsBinding =
+// new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService);
+// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance.
+// // TODO figure out what to do with the service contract
+// ServiceContract<?> contract = new WSDLServiceContract();
+// contract.setInterfaceClass(Greeter.class);
+// return new Axis2ReferenceBinding(URI.create(serviceName),
+// wsBinding,
+// contract,
+// null,
+// null);
+// }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java
new file mode 100644
index 0000000000..d4d20414e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.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;
+
+import junit.framework.TestCase;
+
+public class Axis2ServiceTestCase extends TestCase {
+
+ public void testInvokeService() throws Exception {
+// TestServletHost tomcatHost = new TestServletHost();
+// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, false);
+// axis2Service.start();
+//
+// if (true) return;
+// Servlet servlet = tomcatHost.getMapping("testWebAppName/serviceBindings/testServiceName");
+// assertNotNull(servlet);
+//
+// //Create mocked HttpRequest and HttpResponse object to test the Axis2Servlet
+// //To be done:
+
+ }
+
+ public void testAsyncMessageReceiver() throws Exception {
+
+// TestServletHost tomcatHost = new TestServletHost();
+// Axis2ServiceBinding axis2Service = createAxis2Service("testServiceName", tomcatHost, true);
+// axis2Service.start();
+ }
+
+// @SuppressWarnings("unchecked")
+// private Axis2ServiceBinding createAxis2Service(String serviceName, ServletHost tomcatHost, boolean callback)
+// throws Exception {
+// //Create WebServiceBindingDefinition
+// String wsdlLocation = "/wsdl/hello_world_doc_lit.wsdl";
+// URL url = getClass().getResource(wsdlLocation);
+// assertNotNull("Could not find wsdl " + url.toString(), url);
+//
+// WSDLFactory factory = WSDLFactory.newInstance();
+// WSDLReader reader = factory.newWSDLReader();
+// reader.setFeature("javax.wsdl.verbose", false);
+// InputSource input = new InputSource(url.openStream());
+// Definition wsdlDef = reader.readWSDL(url.toString(), input);
+// Service wsdlService = wsdlDef.getService(new QName("http://objectweb.org/hello_world_soap_http",
+// "SOAPService"));
+// Port port = wsdlService.getPort("SoapPort");
+// WebServiceBindingDefinition wsBinding = new WebServiceBindingDefinition(wsdlDef, port, "uri", "portURI", wsdlService);
+//
+// //Create a mocked WireService, make the call of ServiceBindingExtension.getServiceInstance() returns a proxy instance.
+//// WireService wireService = EasyMock.createNiceMock(WireService.class);
+//// wireService.createProxy(EasyMock.isA(Class.class), EasyMock.isA(Wire.class));
+//// EasyMock.expectLastCall().andReturn(null);
+//// EasyMock.replay(wireService);
+//
+// //Create a mocked InboundWire, make the call of ServiceBindingExtension.getInterface() returns a Class
+// Wire inboundWire = EasyMock.createNiceMock(Wire.class);
+// JavaServiceContract contract = new JavaServiceContract(Greeter.class);
+// Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>();
+// for (Method m : Greeter.class.getMethods()) {
+// opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null));
+// }
+// contract.setOperations(opMap);
+// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes();
+// if (callback) {
+// contract.setCallbackName("");
+// }
+// EasyMock.replay(inboundWire);
+//
+// Wire outboundWire = EasyMock.createNiceMock(Wire.class);
+// Map<Operation<?>, InvocationChain> map = new HashMap<Operation<?>, InvocationChain>();
+// EasyMock.expect(outboundWire.getInvocationChains()).andReturn(map).once();
+// EasyMock.replay(outboundWire);
+//
+// TuscanyAxisConfigurator tuscanyAxisConfigurator = new TuscanyAxisConfigurator();
+// ConfigurationContext configurationContext = tuscanyAxisConfigurator.getConfigurationContext();
+// Axis2ServiceBinding axis2Service =
+// new Axis2ServiceBinding(URI.create(serviceName),
+// contract,
+// null,
+// wsBinding,
+// tomcatHost,
+// configurationContext, null);
+// axis2Service.setWire(inboundWire);
+//// axis2Service.setOutboundWire(outboundWire);
+//
+// return axis2Service;
+// }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java
new file mode 100644
index 0000000000..767f59646f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.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.axis2;
+
+public interface Greeter {
+
+ String sayHi();
+
+ String greetMe(String requestType);
+
+ void greetMeOneWay(String requestType);
+
+ void greetMeWithCallback(String requestType);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java
new file mode 100644
index 0000000000..e5e76af0b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.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 interface GreetingCallback {
+
+ void greetMeCallback(String greetMeResponse);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java
new file mode 100644
index 0000000000..b9407c5778
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java
new file mode 100644
index 0000000000..16ff6f8e8c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java
new file mode 100644
index 0000000000..2dc7d8dee4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java
new file mode 100644
index 0000000000..4ea341f05c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.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.ws.axis2.itests;
+
+/**
+ * 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(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 firstName) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java
new file mode 100644
index 0000000000..4e1e7dbdad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.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.itests;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface Echo {
+
+ Foo echoFoo(Foo foo);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java
new file mode 100644
index 0000000000..3e96480c20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.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.itests;
+
+import org.oasisopen.sca.annotation.Reference;
+
+public class EchoComponent implements Echo {
+
+ @Reference
+ public Echo echoWS;
+
+ public Foo echoFoo(Foo foo) {
+ return echoWS.echoFoo(foo);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java
new file mode 100644
index 0000000000..d028ced69e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.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.itests;
+
+
+public class EchoImpl implements Echo {
+
+ public Foo echoFoo(Foo foo) {
+ return foo;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java
new file mode 100644
index 0000000000..c7b503af17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java
new file mode 100644
index 0000000000..3ac30780b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorld {
+
+ String getGreetings(String s);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java
new file mode 100644
index 0000000000..0dd6e90c72
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java
new file mode 100644
index 0000000000..f30286feea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java
new file mode 100644
index 0000000000..09b414b2d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.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.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;
+
+public class HelloWorldNoWSDLTestCase extends TestCase {
+
+ private Node node;
+
+ public void testHelloWorld() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldComponent");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ /**
+ * Test a a WS call with a complex type
+ */
+ public void testEchoFoo() throws Exception {
+ Echo echo = node.getService(Echo.class, "EchoComponent");
+
+ 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 = echo.echoFoo(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("beate", f2.getBars()[1].getS());
+ assertEquals(3, f2.getBars()[1].getX());
+ assertEquals(4, f2.getBars()[1].getY().intValue());
+ assertFalse(f2.getBars()[1].getB().booleanValue());
+
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java
new file mode 100644
index 0000000000..13a16c8e8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldOM {
+
+ OMElement getGreetings(OMElement parmE);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java
new file mode 100644
index 0000000000..0e50781061
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+import org.apache.axiom.om.OMElement;
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldOM2 {
+
+ OMElement getGreetings2(OMElement parmE);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java
new file mode 100644
index 0000000000..82f61bd7c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java
new file mode 100644
index 0000000000..71d7bf68fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java
new file mode 100644
index 0000000000..4bb5bdb87d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.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.axis2.itests;
+
+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.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+public class HelloWorldOMTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ 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 setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java
new file mode 100644
index 0000000000..017d9bb478
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.itests;
+
+public class HelloWorldService implements HelloWorld {
+
+ public String getGreetings(String s) {
+ return "Hello " + s;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java
new file mode 100644
index 0000000000..b7146098ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/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.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;
+
+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 = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java
new file mode 100644
index 0000000000..1616f80cb4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.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.axis2.itests;
+
+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.ContributionLocationHelper;
+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;
+
+ 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 setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldWSDLMergedComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java
new file mode 100644
index 0000000000..51aa9f25f8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.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.itests;
+
+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.axis2.transport.http.server.HttpUtils;
+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;
+
+/**
+ * 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);
+ // TODO - EPR - $promoted$ no longer used
+ //Service service = definition.getService(new QName("http://account2/AccountService/$promoted$ep1", "AccountService"));
+ Service service = definition.getService(new QName("http://account2/AccountService/Account", "AccountService"));
+ Port port = service.getPort("AccountSoapPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":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 = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java
new file mode 100644
index 0000000000..0b780f2b96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.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.itests;
+
+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.axis2.transport.http.server.HttpUtils;
+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;
+
+/**
+ * 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);
+ // TODO - EPR - $promoted$ no longer used
+ //Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$ep1", "AccountService"));
+ Service service = definition.getService(new QName("http://accounts/AccountService/Account", "AccountService"));
+ Port port = service.getPort("AccountSoapPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":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 = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java
new file mode 100644
index 0000000000..bbec9dd342
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.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.ws.axis2.itests;
+
+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.axis2.transport.http.server.HttpUtils;
+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;
+
+/**
+ * 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/HelloWorldWebService?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/HelloWorldWebService?wsdl");
+ assertNotNull(definition);
+ // TODO - EPR - $promoted$ no longer used
+ //Service service = definition.getService(new QName("http://helloworld/HelloWorldService/$promoted$ep1",
+ // "HelloWorldService"));
+ Service service = definition.getService(new QName("http://helloworld/HelloWorldService/HelloWorld",
+ "HelloWorldService"));
+ Port port = service.getPort("HelloWorldSoapPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8085/services/HelloWorldWebService", 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://itests.axis2.ws.binding.sca.tuscany.apache.org/",
+ "HelloWorldService"));
+ Port port = service.getPort("HelloWorldPort");
+
+ String endpoint = getEndpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":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 = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java
new file mode 100644
index 0000000000..01abbd5382
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.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.itests;
+
+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.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * This test verifies that the Endpoint URI specified in the wsdl takes precedence over the URI specified
+ * in binding. Ref: WS Binding Specification V1.00 - Section 2.1.1
+ *
+ * @version $Rev$ $Date$
+ */
+public class UriPrecedenceTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ public void testUriPrecedence() throws Exception {
+ OMFactory fac = OMAbstractFactory.getOMFactory();
+ OMElement requestOM = fac.createOMElement("getGreetings", "http://helloworld-prec", "helloworld");
+ OMElement parmE = fac.createOMElement("name", "http://helloworld-prec", "helloworld");
+ requestOM.addChild(parmE);
+ parmE.addChild(fac.createOMText("petra"));
+ try {
+ OMElement responseOM = helloWorld.getGreetings(requestOM);
+ OMElement child = (OMElement)responseOM.getFirstElement();
+ Assert.assertEquals("Hello petra", ((OMText)child.getFirstOMChild()).getText());
+ } catch (ServiceRuntimeException e) {
+ fail("Endpoint URI from wsdl did not take precedence over URI in binding.");
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java
new file mode 100644
index 0000000000..a41e0fd2c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.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.ws.axis2.itests.endpoints;
+
+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.itests.HelloWorldOM;
+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 abstract class AbstractHelloWorldOMTestCase extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ 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 setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java
new file mode 100644
index 0000000000..661afdddad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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.itests.endpoints;
+
+public class DefaultMultiServiceTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java
new file mode 100644
index 0000000000..9b2e0eafa0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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.itests.endpoints;
+
+public class DefaultSingleServiceTestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java
new file mode 100644
index 0000000000..98d9a73926
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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.itests.endpoints;
+
+public class WSDLExplicitURITestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java
new file mode 100644
index 0000000000..201d11a79f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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.itests.endpoints;
+
+public class WSDLRelativeURITestCase extends AbstractHelloWorldOMTestCase {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java
new file mode 100644
index 0000000000..23dcd5ff6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/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 org.apache.tuscany.sca.binding.ws.axis2.itests.epr;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.itests.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 = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite", new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorld.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java
new file mode 100644
index 0000000000..e020b03041
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.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.itests.mtom;
+
+import javax.activation.DataHandler;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * locate the FileTransfer service and invoke it.
+ */
+public class FileTransferClient implements FileTransferService {
+
+ @Reference
+ public FileTransferService fileTransferWS;
+
+ public String uploadFile(DataHandler attachment) throws Exception {
+ return fileTransferWS.uploadFile(attachment);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.java
new file mode 100644
index 0000000000..ddd8fc0e5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.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.ws.axis2.itests.mtom;
+
+import javax.activation.DataHandler;
+import javax.activation.FileDataSource;
+
+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.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+
+// Removed imports of old host.embedded function
+// import org.apache.tuscany.sca.host.embedded.SCADomain;
+
+/**
+ *
+ * Modified by Mike Edwards, 4th Dec 2008, to adjust to new interfaces in the 2.0 stream.
+ *
+ */
+public class FileTransferMTOMTestCaseOFF extends TestCase {
+
+ // private SCADomain domain;
+ protected NodeLauncher launcher;
+ protected Node node;
+
+ public void testFileTransfer() throws Exception {
+ // For testing purpose lets try uploading FileTransferClient.java file.
+ DataHandler dataHandler = new DataHandler(new FileDataSource("FileTransferClient.java"));
+ FileTransferService filetransfer = node.getService(FileTransferService.class, "FileTransferServiceComponent");
+ assertEquals("File uploaded Sucessfully", filetransfer.uploadFile(dataHandler));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite");
+ // Tuscany specific code which starts the contribution holding the test
+ launcher = NodeLauncher.newInstance();
+ node = launcher.createNode("filetransferservice.composite", // testConfiguration.getComposite(),
+ new Contribution("FileTransferMTOMTestCase", getContributionURI()));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ //domain.close();
+ if (node != null) {
+ node.stop();
+ node.destroy();
+ }
+ if (launcher != null) {
+ launcher.destroy();
+ }
+ }
+
+ protected String getContributionURI() {
+ Class<?> clazz = getClass();
+ String location = ContributionLocationHelper.getContributionLocation(clazz);
+ return location;
+
+ } // end getContributionURI()
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java
new file mode 100644
index 0000000000..60b28ca4db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.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.axis2.itests.mtom;
+
+import org.oasisopen.sca.annotation.Remotable;
+import javax.activation.DataHandler;
+
+/**
+ * This is the business interface of the HelloWorld greetings service.
+ */
+@Remotable
+public interface FileTransferService {
+
+ public String uploadFile(DataHandler attachment) throws Exception;
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java
new file mode 100644
index 0000000000..6591f2fc32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.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.ws.axis2.itests.mtom;
+
+import javax.activation.DataHandler;
+
+import org.oasisopen.sca.annotation.Service;
+
+/**
+ * This class implements the HelloWorld service.
+ */
+@Service(FileTransferService.class)
+public class FileTransferServiceImpl implements FileTransferService {
+
+ public String uploadFile(DataHandler attachment) throws Exception {
+
+ //OMText binaryNode = (OMText) (attachment.getFirstElement()).getFirstOMChild();
+ //DataHandler dataHandler = (DataHandler) binaryNode.getDataHandler();
+
+ // Use this code to save the file we have received.
+ /*DataHandler dataHandler = attachment;
+
+ File file = new File("transferedfile.java");
+ FileOutputStream fileOutputStream = new FileOutputStream(file);
+ dataHandler.writeTo(fileOutputStream);
+ fileOutputStream.flush();
+ fileOutputStream.close();*/
+
+ System.out.println(attachment.getContentType());
+
+ return "File uploaded Sucessfully";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.java
new file mode 100644
index 0000000000..8c1e6b68da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.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.itests.pojo;
+
+//import java.io.Serializable;
+
+public class Data {
+
+ private Data2[] a = null;
+ private int b = 0;
+ private float c = 0.0f;
+
+ public Data2[] getA() {
+ return this.a;
+ }
+
+ public void setA(Data2[] a) {
+ this.a = a;
+ }
+
+ public int getB() {
+ return this.b;
+ }
+
+ public void setB(int b) {
+ this.b = b;
+ }
+
+ public float getC() {
+ return this.c;
+ }
+
+ public void setC(float c) {
+ this.c = c;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.java
new file mode 100644
index 0000000000..25954a0603
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.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.itests.pojo;
+
+public class Data2 {
+
+ private String[] asdf = null;
+
+ public String[] getAsdf() {
+ return this.asdf;
+ }
+
+ public void setAsdf(String[] asdf) {
+ this.asdf = asdf;
+ }
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.java
new file mode 100644
index 0000000000..3dcbe0d6f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.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.ws.axis2.itests.pojo;
+
+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;
+
+public class POJOWSTestCase {
+
+ @Test
+ public void testWS() throws Exception {
+
+ String location = ContributionLocationHelper.getContributionLocation(TestService.class);
+ Contribution contrib = new Contribution("c1", location);
+ Node node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite", contrib);
+ node.start();
+
+// try {
+// System.out.println("Test server started (press enter to shutdown)");
+// System.in.read();
+// }
+// catch (IOException e) {
+// System.err.println(e);
+// e.printStackTrace();
+// }
+
+ node.stop();
+ System.out.println("Test server stopped");
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.java
new file mode 100644
index 0000000000..c055d4909f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.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.itests.pojo;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+
+@Remotable
+public interface TestService {
+
+ public boolean printData(Data data);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.java
new file mode 100644
index 0000000000..4eec594a47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.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.itests.pojo;
+
+import java.util.Arrays;
+
+import org.oasisopen.sca.annotation.Service;
+
+@Service(TestService.class)
+public class TestServiceImpl implements TestService {
+
+ public boolean printData(Data data) {
+ if (data == null) {
+ System.out.println("data is null");
+ return false;
+ }
+
+ StringBuilder sb = new StringBuilder(256);
+ sb.append("Data:\n");
+ Data2[] a = data.getA();
+ if (a != null) {
+ for (int i = 0; i < a.length; i++) {
+ sb.append(" a[");
+ sb.append(i);
+ sb.append("] = ");
+ sb.append(Arrays.asList(a[i].getAsdf()));
+ sb.append("\n");
+ }
+ } else {
+ sb.append(" a = null");
+ }
+ sb.append("\n b = ");
+ sb.append(data.getB());
+ sb.append("\n c = ");
+ sb.append(data.getC());
+ sb.append("\n");
+
+ System.out.println(sb.toString());
+
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/package-info.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/package-info.java
new file mode 100644
index 0000000000..9224baae29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/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://test/server")
+package org.apache.tuscany.sca.binding.ws.axis2.itests.pojo;
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.java
new file mode 100644
index 0000000000..270ec4d097
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.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.ws.axis2.itests.policy.configparams;
+
+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.itests.HelloWorldOM;
+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 abstract class AbstractHelloWorldOMTestCaseOFF extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ 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 setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java
new file mode 100644
index 0000000000..ff2d96c3a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.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.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Client UserId/Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java
new file mode 100644
index 0000000000..0b5a5031ce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.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.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntegrityPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Integrity Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java
new file mode 100644
index 0000000000..14e69e7989
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.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.itests.policy.configparams;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler....");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java
new file mode 100644
index 0000000000..e27514681b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.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.itests.policy.configparams;
+
+public class WSSecurityAuthenticationTestCaseFIXME extends AbstractHelloWorldOMTestCaseOFF {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java
new file mode 100644
index 0000000000..fde1864e43
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.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.itests.policy.configparams;
+
+import java.security.Provider;
+import java.security.Security;
+
+public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCaseOFF {
+
+ /**
+ * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ // Workaround an issue with IBM JDK
+ Provider jce = Security.getProvider("IBMJCE");
+ if (jce != null) {
+ // Make sure IBMJCE is used first
+ Security.removeProvider("IBMJCE");
+ Security.insertProviderAt(jce, 1);
+ }
+ super.setUp();
+ }
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.java
new file mode 100644
index 0000000000..7144ad4b41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.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.itests.policy.configparams;
+
+public class WSSecurityIntegrityTestCaseOFF extends AbstractHelloWorldOMTestCaseOFF {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.java
new file mode 100644
index 0000000000..a6223a3ccc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.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.axis2.itests.policy.mixed;
+
+import junit.framework.Assert;
+
+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.itests.HelloWorldOM;
+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 abstract class AbstractHelloWorldOMTestCaseOFF {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ @Test
+ 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());
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java
new file mode 100644
index 0000000000..88fc0d63fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.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.ws.axis2.itests.policy.mixed;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Client UserId/Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+
+ System.out.println(" **** 1. UserId : " + pwcb.getIdentifer());
+ System.out.println(" **** 2. Passwd : " + pwcb.getPassword());
+ System.out.println(" **** 3. Usage : " + pwcb.getUsage());
+
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java
new file mode 100644
index 0000000000..0d8914156f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.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.ws.axis2.itests.policy.mixed;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntegrityPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Integrity Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+
+ System.out.println(" **** 1. UserId : " + pwcb.getIdentifer());
+ System.out.println(" **** 2. Passwd : " + pwcb.getPassword());
+ System.out.println(" **** 3. Usage : " + pwcb.getUsage());
+
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java
new file mode 100644
index 0000000000..5840f71057
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.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.itests.policy.mixed;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler....");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ System.out.println(" **** 1. UserId : " + pwcb.getIdentifer());
+ System.out.println(" **** 2. Passwd : " + pwcb.getPassword());
+ System.out.println(" **** 3. Usage : " + pwcb.getUsage());
+
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java
new file mode 100644
index 0000000000..cdf96bdb58
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.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.ws.axis2.itests.policy.mixed;
+
+import org.junit.Ignore;
+
+@Ignore("Temporarily ignore rampart module validation failure")
+public class WSSecurityMixedTestCase extends AbstractHelloWorldOMTestCaseOFF {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.java
new file mode 100644
index 0000000000..81f2690709
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.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.ws.axis2.itests.policy.wspolicy;
+
+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.itests.HelloWorldOM;
+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 abstract class AbstractHelloWorldOMTestCaseOFF extends TestCase {
+
+ private Node node;
+ private HelloWorldOM helloWorld;
+
+ 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 setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode(getCompositeName(), new Contribution("test", contribution));
+ node.start();
+ helloWorld = node.getService(HelloWorldOM.class, "HelloWorldComponent");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+ protected String getCompositeName() {
+ String className = this.getClass().getName();
+ return className.substring(0, className.length() - 8).replace('.', '/') + ".composite";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java
new file mode 100644
index 0000000000..1437c2c866
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.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.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ClientPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Client UserId/Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java
new file mode 100644
index 0000000000..915c4f51c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.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.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class IntegrityPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Integrity Password Handler .... ");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java
new file mode 100644
index 0000000000..8f3cd9fe32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.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.itests.policy.wspolicy;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.WSPasswordCallback;
+
+/**
+ * Sample userid passwd generation class
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServerPWCBHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ System.out.println("*** Calling Server User/Passwd Handler....");
+ WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
+ pwcb.setPassword("TuscanyWsUserPasswd");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.java
new file mode 100644
index 0000000000..9070053ece
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.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.ws.axis2.itests.policy.wspolicy;
+
+import org.junit.Ignore;
+
+@Ignore("Temporarily ignore rampart module validation failure")
+public class WSSecurityAuthenticationTestCaseOFF extends AbstractHelloWorldOMTestCaseOFF {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java
new file mode 100644
index 0000000000..2bd6d41427
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.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.itests.policy.wspolicy;
+
+import java.security.Provider;
+import java.security.Security;
+
+public class WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue extends AbstractHelloWorldOMTestCaseOFF {
+
+ /**
+ * @see org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.AbstractHelloWorldOMTestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ // Workaround an issue with IBM JDK
+ Provider jce = Security.getProvider("IBMJCE");
+ if (jce != null) {
+ // Make sure IBMJCE is used first
+ Security.removeProvider("IBMJCE");
+ Security.insertProviderAt(jce, 1);
+ }
+ super.setUp();
+ }
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.java
new file mode 100644
index 0000000000..dd215180fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.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.ws.axis2.itests.policy.wspolicy;
+
+import org.junit.Ignore;
+
+@Ignore("Temporarily ignore rampart module validation failure")
+public class WSSecurityIntegrityTestCaseOFF extends AbstractHelloWorldOMTestCaseOFF {
+ // super class does it all getting composite based on this class name
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.java
new file mode 100644
index 0000000000..45c0a6932a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.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.itests.soap12 ;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.binding.ws.axis2.itests.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 HelloWorldSOAP12TestCaseOFF extends TestCase {
+
+ private Node node;
+
+ public void testHelloWorld() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClient");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+ public void testHelloWorldSOAP() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientSOAP");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+ public void testHelloWorldSOAP11() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientSOAP11");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+ public void testHelloWorldSOAP12() throws Exception {
+ HelloWorld helloWorld = node.getService(HelloWorld.class, "HelloWorldClientSOAP12");
+ assertEquals("Hello petra", helloWorld.getGreetings("petra"));
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite", new Contribution("test", contribution));
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.java
new file mode 100644
index 0000000000..c74ffee695
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.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.ws.axis2.itests.soap12;
+
+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.extensions.soap12.SOAP12Address;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.axis2.transport.http.server.HttpUtils;
+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;
+
+/**
+ * Test ?wsdl works and that the returned WSDL has the correct endpoint
+ *
+ * @version $Rev$ $Date$
+ */
+public class QuestionMarkWSDLTestCaseOFF extends TestCase {
+
+ private static boolean newGenerator = true;
+ private Node node;
+
+ /**
+ * Tests ?wsdl returns a soap 1.1 port by default
+ */
+ public void testSOAPDefault() throws Exception {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep1?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName(
+ "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""),
+ newGenerator ? "HelloWorldService" : "HelloWorld"));
+ Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http");
+
+ String endpoint = getSOAP11Endpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8085/ep1", endpoint);
+ }
+
+ /**
+ * Tests ?wsdl returns a soap 1.1 port when binding uses requires="SOAP.1_1"
+ */
+ public void testSOAP11Endpoint() throws Exception {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep2?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName(
+ "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""),
+ newGenerator ? "HelloWorldService" : "HelloWorld"));
+ Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http");
+
+ String endpoint = getSOAP11Endpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8085/ep2", endpoint);
+ }
+
+ /**
+ * Tests ?wsdl returns a soap 1.2 port when binding uses requires="SOAP.1_2"
+ */
+ public void testSOAP12Endpoint() throws Exception {
+ WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.verbose",false);
+ wsdlReader.setFeature("javax.wsdl.importDocuments",true);
+
+ Definition definition = wsdlReader.readWSDL("http://localhost:8085/ep3?wsdl");
+ assertNotNull(definition);
+ Service service = definition.getService(new QName(
+ "http://itests.axis2.ws.binding.sca.tuscany.apache.org" + (newGenerator ? "/" : ""),
+ newGenerator ? "HelloWorldService" : "HelloWorld"));
+ Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP12port_http");
+
+ String endpoint = getSOAP12Endpoint(port);
+ String ip = HttpUtils.getIpAddress();
+ assertEquals("http://" + ip + ":8085/ep3", endpoint);
+ }
+
+ protected String getSOAP11Endpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAPAddress) {
+ return ((SOAPAddress) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ protected String getSOAP12Endpoint(Port port) {
+ List wsdlPortExtensions = port.getExtensibilityElements();
+ for (final Object extension : wsdlPortExtensions) {
+ if (extension instanceof SOAP12Address) {
+ return ((SOAP12Address) extension).getLocationURI();
+ }
+ }
+ throw new RuntimeException("no SOAPAddress");
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ String contribution = ContributionLocationHelper.getContributionLocation(getClass());
+ node = NodeFactory.newInstance().createNode("org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite", new Contribution("test", contribution));
+ node.start();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ node.stop();
+ node.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
new file mode 100644
index 0000000000..9f9d98d861
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler
@@ -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.
+#
+# PolicyHandlerClasses to interpret specific PolicyModels against specific QoS infrastructures
+# handler classname;qname=<policy intent addressed>;model=<policy model class>
+org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicyHandler;intent=http://tuscany.apache.org/xmlns/sca/1.1#wsAuthentication,model=org.apache.tuscany.sca.policy.security.ws.Axis2ConfigParamPolicy
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite
new file mode 100644
index 0000000000..f8e3f11284
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.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/HelloWorldWebService</wsa:Address>
+ </wsa:EndpointReference>
+ </binding.ws>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld#wsdl.port(HelloWorldService/HelloWorldSoapPort)"/>
+ </reference>
+ </component>
+
+
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite
new file mode 100644
index 0000000000..3c8ed37414
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorldNoWSDL">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ <service name="HelloWorld" >
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" >
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </reference>
+ </component>
+
+ <component name="EchoService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.EchoImpl"/>
+ <service name="Echo">
+ <binding.ws uri="http://localhost:8085/Echo"/>
+ </service>
+ </component>
+
+ <component name="EchoComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.EchoComponent"/>
+ <reference name="echoWS">
+ <binding.ws uri="http://localhost:8085/Echo"/>
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd
new file mode 100644
index 0000000000..421d5d6166
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd
new file mode 100644
index 0000000000..39d814ea40
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/itests/customerinfo.xsd" />
+
+</xsd:schema>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd
new file mode 100644
index 0000000000..b78909142f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite
new file mode 100644
index 0000000000..9c11895223
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite
new file mode 100644
index 0000000000..5852d58b19
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite
new file mode 100644
index 0000000000..d72d0b4239
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite
new file mode 100644
index 0000000000..aefe1b41a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl
new file mode 100644
index 0000000000..fe68755c47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite
new file mode 100644
index 0000000000..1d3ea6e91e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl
new file mode 100644
index 0000000000..7bf47bc412
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.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-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-bindings">
+
+ <wsdl:import namespace="http://helloworld-om-merged"
+ location="helloworld-om-porttype.wsdl"/>
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite
new file mode 100644
index 0000000000..4367e2d88d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.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.itests.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl
new file mode 100644
index 0000000000..29be66fb71
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl
new file mode 100644
index 0000000000..baa223f41c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite
new file mode 100644
index 0000000000..24a66ccbca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorldOM">
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-om#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld" />
+ </reference>
+ </component>
+
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl
new file mode 100644
index 0000000000..73ca02246d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite
new file mode 100644
index 0000000000..4d605a2012
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorldPrec">
+
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ <service name="HelloWorldOM">
+ <interface.wsdl interface="http://helloworld-prec#wsdl.interface(HelloWorld)" />
+ <binding.ws uri="http://localhost:8085/HelloWorldService/helloWorld"/>
+ </service>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS">
+ <interface.wsdl interface="http://helloworld-prec#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-prec#wsdl.port(HelloWorldService/HelloWorldSoapPort)"
+ uri="http://INVALID.END.POINT" />
+ </reference>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl
new file mode 100644
index 0000000000..5908c43e7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl
@@ -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.
+-->
+
+<!-- $Rev$ $Date$ -->
+
+<wsdl:definitions targetNamespace="http://helloworld-prec" xmlns:tns="http://helloworld-prec" 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-prec">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://helloworld-prec" 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl
new file mode 100644
index 0000000000..1a2272d7ee
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl
new file mode 100644
index 0000000000..8887b3452f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.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://filetransfer"
+ xmlns:tns="http://filetransfer"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ name="filetransfer">
+
+ <wsdl:types>
+ <schema elementFormDefault="qualified" targetNamespace="http://filetransfer" xmlns="http://www.w3.org/2001/XMLSchema">
+
+ <element name="uploadFile">
+ <complexType>
+ <sequence>
+ <element name="attachment" type="xsd:base64Binary"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="uploadFileResponse">
+ <complexType>
+ <sequence>
+ <element name="uploadFileReturn" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ </schema>
+ </wsdl:types>
+
+ <wsdl:message name="uploadFileRequest">
+ <wsdl:part element="tns:uploadFile" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:message name="uploadFileResponse">
+ <wsdl:part element="tns:uploadFileResponse" name="parameters"/>
+ </wsdl:message>
+
+ <wsdl:portType name="FileTransfer">
+ <wsdl:operation name="uploadFile">
+ <wsdl:input message="tns:uploadFileRequest" name="uploadFileRequest"/>
+ <wsdl:output message="tns:uploadFileResponse" name="uploadFileResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+
+ <wsdl:binding name="FileTransferSoapBinding" type="tns:FileTransfer">
+ <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="uploadFile">
+ <wsdlsoap:operation soapAction=""/>
+ <wsdl:input name="uploadFileRequest">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:input>
+ <wsdl:output name="uploadFileResponse">
+ <wsdlsoap:body use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="FileTransferService">
+ <wsdl:port binding="tns:FileTransferSoapBinding" name="FileTransferSoapPort">
+ <wsdlsoap:address location="http://localhost:8085/FileTransferServiceComponent"/>
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF
new file mode 100644
index 0000000000..3dcef5ab46
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF
@@ -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/200903"
+ targetNamespace="http://filetransfer"
+ xmlns:hw="http://filetransfer"
+ name="filetransferws">
+
+ <component name="FileTransferServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferServiceImpl" />
+ <service name="FileTransferService">
+ <interface.wsdl interface="http://filetransfer#wsdl.interface(FileTransfer)" />
+ <binding.ws uri="http://localhost:8085/FileTransferService"/>
+ </service>
+ </component>
+
+ <component name="FileTransferClientComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferClient"/>
+ <reference name="fileTransferWS" />
+ </component>
+
+ <reference name="fileTransferWS" promote="FileTransferClientComponent/fileTransferWS">
+ <binding.ws uri="http://localhost:8085/FileTransferService"/>
+ </reference>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite
new file mode 100644
index 0000000000..74aff65651
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.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/200903"
+ targetNamespace="http://test"
+ xmlns:hw="http://helloworld"
+ name="test">
+ <component name="TestServiceComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.pojo.TestServiceImpl" />
+ <service name="TestService">
+ <interface.java interface="org.apache.tuscany.sca.binding.ws.axis2.itests.pojo.TestService" />
+ <binding.ws uri="http://localhost:8085/testService"/>
+ </service>
+ </component>
+</composite>
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF
new file mode 100644
index 0000000000..60673ab103
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF
@@ -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/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="authentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsClientAuthenticationPolicy">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF
new file mode 100644
index 0000000000..bc3107c388
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF
@@ -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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="confidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" requires="confidentiality">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF
new file mode 100644
index 0000000000..ae07495cf3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF
@@ -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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" requires="integrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" requires="integrity">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml
new file mode 100644
index 0000000000..e46345bdbc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml
@@ -0,0 +1,101 @@
+<?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/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- WS Security POLICY SETS -->
+ <sca:policySet name="wsAuthenticationPolicy"
+ provides="sca:authentication"
+ appliesTo="//sca:binding.ws"
+ >
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ServerPWCBHandler</passwordCallbackClass>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsClientAuthenticationPolicy"
+ provides="tuscany:wsAuthentication"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <user>TuscanyWsUser</user>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ClientPWCBHandler</passwordCallbackClass>" +
+ <passwordType>PasswordText</passwordType>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsIntegrityPolicy"
+ provides="sca:integrity"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp Signature</items>
+ <user>TuscanyWsUser</user>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>" +
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsConfidentialityPolicy"
+ provides="sca:confidentiality"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Timestamp Signature Encrypt</items>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Timestamp Signature Encrypt</items>
+ <user>TuscanyWsUser</user>
+ <encryptionUser>TuscanyWsUser</encryptionUser>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler</passwordCallbackClass>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties</signaturePropFile>
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ <encryptionKeyIdentifier>SKIKeyIdentifier</encryptionKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+ </sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties
new file mode 100644
index 0000000000..cb188e6676
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties
@@ -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.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd
+org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks
new file mode 100644
index 0000000000..307edb9b37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml
new file mode 100644
index 0000000000..19a8521f61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml
@@ -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.
+-->
+<sca:definitions xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:intent name="wsAuthentication"
+ constrains="sca:binding.ws">
+ <description>
+ Communitcation thro this binding required Authentication.
+ </description>
+ </sca:intent>
+
+ </sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF
new file mode 100644
index 0000000000..9a2ed7d29a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF
@@ -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/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="WSSecurityMixed">
+
+ <!--
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService"
+ policySets="tuscany:serverWsPolicyForAuthentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS"
+ policySets="tuscany:clientWsPolicyForAuthentication">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml
new file mode 100644
index 0000000000..fb08fee447
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml
@@ -0,0 +1,323 @@
+<?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/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- WS Security POLICY SETS -->
+ <sca:policySet name="wsAuthenticationPolicy"
+ provides="sca:authentication"
+ appliesTo="//sca:binding.ws"
+ >
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsClientAuthenticationPolicy"
+ provides="tuscany:wsAuthentication"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>UsernameToken</items>
+ <user>TuscanyWsUser</user>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler</passwordCallbackClass>" +
+ <passwordType>PasswordText</passwordType>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsMixedReceiverIntegrityPolicy"
+ provides="sca:integrity"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsMixedSenderIntegrityPolicy"
+ provides="sca:integrity"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Signature</items>
+ <user>TuscanyWsUser</user>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler</passwordCallbackClass>
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsServerAuthenticationIntegrityPolicy"
+ provides="sca:authentication sca:integrity"
+ appliesTo="//sca:binding.ws"
+ >
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>UsernameToken Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>Signature</items>
+ <user>TuscanyWsUser</user>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</passwordCallbackClass>
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="wsClientAuthenticationIntegrityPolicy"
+ provides="tuscany:wsAuthentication"
+ appliesTo="//sca:binding.ws">
+ <tuscany:wsConfigParam>
+ <parameter name="InflowSecurity">
+ <action>
+ <items>Signature</items>
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ </action>
+ </parameter>
+ <parameter name="OutflowSecurity">
+ <action>
+ <items>UsernameToken Signature</items>
+ <user>TuscanyWsUser</user>
+ <passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler</passwordCallbackClass>" +
+ <signaturePropFile>org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties</signaturePropFile>
+ <passwordType>PasswordText</passwordType>
+ <signatureKeyIdentifier>DirectReference</signatureKeyIdentifier>
+ </action>
+ </parameter>
+ </tuscany:wsConfigParam>
+ </sca:policySet>
+
+ <sca:policySet name="clientWsPolicyForAuthentication"
+ provides="sca:authentication"
+ appliesTo="//sca:binding.ws"
+ >
+ <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.mixed.ClientPWCBHandler</ramp:passwordCallbackClass>
+ </ramp:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+ <sca:policySet name="serverWsPolicyForAuthentication"
+ provides="sca:authentication"
+ appliesTo="//sca:binding.ws"
+ >
+ <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:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler</ramp:passwordCallbackClass>
+ </ramp:RampartConfig>
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="serverWsPolicyForIntegrity"
+ provides="sca:integrity"
+ appliesTo="//sca:binding.ws">
+ <wsp:Policy wsu:Id="SignOnly"
+ 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:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+
+ <!-- A policyset that uses WS Policy -->
+ <!-- sca:policySet name="tuscany:wsSecurityPolicyForIntegritys"
+ provides="sca:integrity"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="SignOnly"
+ 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:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet-->
+ </sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties
new file mode 100644
index 0000000000..cb188e6676
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties
@@ -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.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
+org.apache.ws.security.crypto.merlin.keystore.type=jks
+org.apache.ws.security.crypto.merlin.keystore.password=TuscanyWsUserPasswd
+org.apache.ws.security.crypto.merlin.file=org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks
new file mode 100644
index 0000000000..307edb9b37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF
new file mode 100644
index 0000000000..780130e699
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF
@@ -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/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsSecurityPolicyForAuthentication">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsSecurityPolicyForAuthentication">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF
new file mode 100644
index 0000000000..dd0a102476
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF
@@ -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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="wsSecurityPolicyForConfidentiality">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="wsSecurityPolicyForConfidentiality">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF
new file mode 100644
index 0000000000..904c0b469e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF
@@ -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/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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
+ -->
+
+ <service name="helloWorld" promote="HelloWorldService" policySets="tuscany:wsSecurityPolicyForIntegrity">
+ <interface.wsdl interface="http://helloworld-om-uri#wsdl.interface(HelloWorld)" />
+ <binding.ws wsdlElement="http://helloworld-om-uri#wsdl.port(HelloWorldService/HelloWorldSoapPort)" />
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMService"/>
+ </component>
+
+ <component name="HelloWorldComponent">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldOMComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldComponent/helloWorldWS" policySets="tuscany:wsSecurityPolicyForIntegrity">
+ <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>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml
new file mode 100644
index 0000000000..8a5aacf916
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml
@@ -0,0 +1,203 @@
+<?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/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- WS Security POLICY SETS -->
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForAuthentication"
+ provides="sca:authentication"
+ appliesTo="sca:binding.ws">
+ <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>
+ </sca:policySet>
+
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForIntegrity"
+ provides="sca:integrity"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="SignOnly"
+ 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:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+ </wsp:Policy>
+ </sca:policySet>
+
+ <!-- A policyset that uses WS Policy -->
+ <sca:policySet name="wsSecurityPolicyForConfidentiality"
+ provides="sca:confidentiality"
+ appliesTo="sca:binding.ws">
+ <wsp:Policy wsu:Id="SigEncr" 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:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:TripleDesRsa15/>
+ </wsp:Policy>
+ </sp:AlgorithmSuite>
+ <sp:Layout>
+ <wsp:Policy>
+ <sp:Strict/>
+ </wsp:Policy>
+ </sp:Layout>
+ <sp:IncludeTimestamp/>
+ <sp:OnlySignEntireHeadersAndBody/>
+ </wsp:Policy>
+ </sp:AsymmetricBinding>
+ <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:MustSupportRefKeyIdentifier/>
+ <sp:MustSupportRefIssuerSerial/>
+ </wsp:Policy>
+ </sp:Wss10>
+ <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:SignedParts>
+ <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <sp:Body/>
+ </sp:EncryptedParts>
+
+ <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">
+ <ramp:user>TuscanyWsUser</ramp:user>
+ <ramp:encryptionUser>TuscanyWsUser</ramp:encryptionUser>
+ <ramp:passwordCallbackClass>org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler</ramp:passwordCallbackClass>
+ <ramp:signatureCrypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:signatureCrypto>
+
+ <ramp:encryptionCypto>
+ <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.file">org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks</ramp:property>
+ <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">TuscanyWsUserPasswd</ramp:property>
+ </ramp:crypto>
+ </ramp:encryptionCypto>
+ </ramp:RampartConfig>
+
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
+ </sca:policySet>
+
+ </sca:definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks
new file mode 100644
index 0000000000..307edb9b37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl
new file mode 100644
index 0000000000..686b08a1d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl
new file mode 100644
index 0000000000..99a8c6d81d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/itests/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl
new file mode 100644
index 0000000000..80e4b62801
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.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 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/itests/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="xsd:string" />
+ <!--
+ <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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite
new file mode 100644
index 0000000000..95e93419da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/200903"
+ 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.itests.AccountService" />
+ <service name="Account">
+ <binding.ws wsdlElement="http://account2#wsdl.port(AccountService/AccountSoapPort)" />
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite
new file mode 100644
index 0000000000..9f035663bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/200903"
+ 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.itests.AccountService" />
+ <service name="Account">
+ <binding.ws wsdlElement="http://accounts#wsdl.port(AccountService/AccountSoapPort)" />
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite
new file mode 100644
index 0000000000..3ed8b206a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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.itests.HelloWorldService"/>
+ <service name="HelloWorld">
+ <binding.ws name="ep1" uri="http://localhost:8085/foo/bar" />
+ <binding.ws name="ep2" wsdlElement="http://helloworld#wsdl.service(HelloWorldService)"/>
+ </service>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF
new file mode 100644
index 0000000000..f7caa55fce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF
@@ -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.
+-->
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="HelloWorld">
+
+ <service name="helloWorld" promote="HelloWorldService">
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </service>
+ <service name="helloWorldSOAP" promote="HelloWorldService">
+ <binding.ws requires="SOAP" uri="http://localhost:8085/helloWorldSOAP"/>
+ </service>
+ <service name="helloWorldSOAP11" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_1" uri="http://localhost:8085/helloWorldSOAP11"/>
+ </service>
+ <service name="helloWorldSOAP12" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_2" uri="http://localhost:8085/helloWorldSOAP12"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+ <component name="HelloWorldClient">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP11">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+ <component name="HelloWorldClientSOAP12">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldComponent"/>
+ <reference name="helloWorldWS" />
+ </component>
+
+ <reference name="helloWorldWS" promote="HelloWorldClient/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorld"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP" requires="SOAP"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP11/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP11" requires="SOAP.1_1"/>
+ </reference>
+ <reference name="helloWorldWS" promote="HelloWorldClientSOAP12/helloWorldWS">
+ <binding.ws uri="http://localhost:8085/helloWorldSOAP12" requires="SOAP.1_2"/>
+ </reference>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF
new file mode 100644
index 0000000000..6118743da3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF
@@ -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/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ targetNamespace="http://www.tuscany.apache.org/tests/binding/ws/axis2"
+ name="QuestionMarkWSDLTests">
+
+ <service name="ep1" promote="HelloWorldService">
+ <binding.ws uri="http://localhost:8085/ep1"/>
+ </service>
+
+ <service name="ep2" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_1" uri="http://localhost:8085/ep2"/>
+ </service>
+
+ <service name="ep3" promote="HelloWorldService">
+ <binding.ws requires="SOAP.1_2" uri="http://localhost:8085/ep3"/>
+ </service>
+
+ <component name="HelloWorldService">
+ <implementation.java class="org.apache.tuscany.sca.binding.ws.axis2.itests.HelloWorldService"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5d7c3a3457
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
@@ -0,0 +1,62 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Web Service binding WSDL Generator
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397303515
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/pom.xml
new file mode 100644
index 0000000000..9cfa2491d7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java-jaxws</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-ws-axis2-policy</artifactId>
+ <version>2.0-M4</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-core-databinding</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
new file mode 100644
index 0000000000..67a165f1f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.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.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.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.Operation;
+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/200903", "SOAP.1_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) {
+ 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, 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);
+ }
+
+ // TODO - fix up the conversational flag and operation sequences in case the contract has come from WSDL
+ // as we don't yet support requires="conversational" or sca:endConversation annotations
+ // in WSDL interface descriptions (see section 1.5.4 of the Assembly Specification V1.0)
+ if (contract.getInterfaceContract().getInterface() != null ) {
+ icontract.getInterface().setConversational(contract.getInterfaceContract().getInterface().isConversational());
+
+ for (Operation operation : icontract.getInterface().getOperations()){
+ Operation serviceOperation = null;
+
+ for (Operation tmpOp : contract.getInterfaceContract().getInterface().getOperations()){
+ if (operation.getName().equals(tmpOp.getName())) {
+ serviceOperation = tmpOp;
+ break;
+ }
+ }
+
+ if (serviceOperation != null ){
+ operation.setConversationSequence(serviceOperation.getConversationSequence());
+ }
+ }
+ }
+
+ /*
+ // 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.getWSDLDocument();
+ if (definition == null) {
+ definition = WSDLServiceGenerator.configureWSDLDefinition(wsBinding, component, contract, monitor);
+ wsBinding.setWSDLDocument(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
+ */
+ protected static WSDLInterfaceContract createWSDLInterfaceContract(JavaInterfaceContract contract,
+ boolean requiresSOAP12,
+ ModelResolver resolver,
+ DataBindingExtensionPoint dataBindings,
+ WSDLFactory wsdlFactory,
+ XSDFactory xsdFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ Monitor monitor) {
+
+ WSDLInterfaceContract wsdlContract = wsdlFactory.createWSDLInterfaceContract();
+ WSDLInterface wsdlInterface = wsdlFactory.createWSDLInterface();
+ wsdlContract.setInterface(wsdlInterface);
+
+ WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
+ JavaInterface iface = (JavaInterface)contract.getInterface();
+
+ Definition def = null;
+ try {
+ Interface2WSDLGenerator wsdlGenerator =
+ new Interface2WSDLGenerator(requiresSOAP12, resolver, dataBindings, xsdFactory, documentBuilderFactory, monitor);
+ def = wsdlGenerator.generate(iface, wsdlDefinition);
+ } catch (WSDLException e) {
+ throw new WSDLGenerationException(e);
+ }
+
+ // for debugging
+ if (printWSDL) {
+ try {
+ System.out.println("Generated WSDL for Java interface " + iface.getName() + " class " + iface.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.setConversational(contract.getInterface().isConversational());
+ 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 wsdlContract;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
new file mode 100644
index 0000000000..7509f2ab57
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java
@@ -0,0 +1,887 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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);
+ }
+ TypeInfo typeInfo = helper.getTypeInfo(javaType.isArray() ? javaType.getComponentType() : javaType,
+ dataType.getLogical());
+ ElementInfo element = new ElementInfo(name, typeInfo);
+ element.setMany(byte[].class != javaType && 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
new file mode 100644
index 0000000000..bfd95bd292
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java
@@ -0,0 +1,512 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.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/200903", "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);
+ // TODO - EPR - $promoted$ no longer used
+ /*
+ // For every promoted composite service, the underlying component
+ // gets a copy of the service with the name prefixed by "$promoted$."
+ String contractName = (contract instanceof CompositeService ? "$promoted$." : "") + contract.getName();
+ */
+ String contractName = contract.getName();
+
+ List<Port> ports = new ArrayList<Port>();
+ WSDLDefinition wsdlDefinition = wsBinding.getWSDLDefinition();
+ 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);
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
new file mode 100644
index 0000000000..e30298db33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.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.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) {
+ BindingWSDLGenerator.generateWSDL(component, contract, binding, extensionPoints, context.getMonitor());
+ }
+
+ public QName getBindingType() {
+ return WebServiceBinding.TYPE;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder
new file mode 100644
index 0000000000..985d9cb88d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#binding.ws
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties
new file mode 100644
index 0000000000..a94c1d9bef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = Exception while generating WSDL: {0}
+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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java
new file mode 100644
index 0000000000..d147d85ef3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(dataBindings, faultExceptionMapper, null).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(dataBindings, faultExceptionMapper, null).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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java
new file mode 100644
index 0000000000..33d5bea838
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(dataBindings, faultExceptionMapper, null).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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7546d43106
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/META-INF/MANIFEST.MF
@@ -0,0 +1,43 @@
+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"
+Private-Package: org.apache.tuscany.sca.binding.ws.impl;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA WS Binding Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397286828
+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.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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/pom.xml
new file mode 100644
index 0000000000..b98fb5040e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/pom.xml
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>wsdl4j</groupId>
+ <artifactId>wsdl4j</artifactId>
+ <version>1.6.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
new file mode 100644
index 0000000000..5e0f8a0a88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
@@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.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 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.
+ * @return the WSDL definition
+ */
+ WSDLDefinition getWSDLDefinition();
+
+ /**
+ * Sets the WSDL definition.
+ * @param wsdlDefinition the WSDL definition
+ */
+ void setDefinition(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 getWSDLDocument();
+
+ /**
+ * Sets the generated WSDL definitions document.
+ * @param definition the generated WSDL definitions document
+ */
+ void setWSDLDocument(Definition definition);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java
new file mode 100644
index 0000000000..1ad38c69e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
new file mode 100644
index 0000000000..c1981b8809
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.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.binding.ws.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.assembly.Extension;
+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 WSDLDefinition wsdlDefinition;
+ private String wsdlNamespace;
+ private InterfaceContract bindingInterfaceContract;
+ private Element endPointReference;
+ private Definition generatedWSDLDocument;
+
+ 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 (getWSDLDefinition() != null && wsdlDefinition.getBinding() != null) {
+ binding = wsdlDefinition.getBinding();
+ }
+ }
+ 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;
+ }
+
+ 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 getWSDLDefinition() {
+ if (wsdlDefinition == null) {
+ Interface iface = bindingInterfaceContract.getInterface();
+ if (iface instanceof WSDLInterface) {
+ wsdlDefinition = ((WSDLInterface) iface).getWsdlDefinition();
+ }
+ }
+ return wsdlDefinition;
+ }
+
+ public void setDefinition(WSDLDefinition wsdlDefinition) {
+ this.wsdlDefinition = 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 getWSDLDocument() {
+ return generatedWSDLDocument;
+ }
+
+ public void setWSDLDocument(Definition definition) {
+ this.generatedWSDLDocument = definition;
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
new file mode 100644
index 0000000000..2966a1ef81
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.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.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+import java.util.Map;
+
+import javax.wsdl.Binding;
+import javax.wsdl.Port;
+import javax.wsdl.PortType;
+import javax.wsdl.Service;
+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.ws.WebServiceBinding;
+import org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory;
+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 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);
+ }
+
+ // Read URI
+ String uri = reader.getAttributeValue(null, URI);
+ if (uri != null) {
+ wsBinding.setURI(uri);
+ }
+
+ // Read a qname in the form:
+ // namespace#wsdl.???(name)
+ Boolean wsdlElementIsBinding = null;
+ String wsdlElement = reader.getAttributeValue(null, 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")) {
+
+ // Read a wsdl.service
+ localName = localName.substring("wsdl.service(".length(), localName.length() - 1);
+ wsBinding.setServiceName(new QName(namespace, localName));
+
+ } 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));
+ }
+ } 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
+ wsBinding.setLocation(reader.getAttributeValue(WSDLI_NS, WSDL_LOCATION));
+
+ // 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));
+ }
+ }
+ break;
+
+ }
+
+ if (event == END_ELEMENT && BINDING_WS_QNAME.equals(reader.getName())) {
+ break;
+ }
+ }
+ 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 location
+ if (wsBinding.getLocation() != null) {
+ writer.writeAttribute(WSDLI_NS, WSDL_LOCATION, wsBinding.getLocation());
+ }
+
+ 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 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.setDefinition(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 {
+ warning(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());
+ if (model.getPortName() != null) {
+ Port port = service.getElement().getPort(model.getPortName());
+ if (port != null) {
+ model.setPort(port);
+ model.setBinding(port.getBinding());
+ } else {
+ warning(monitor, "WsdlPortTypeDoesNotMatch", wsdlDefinition, model.getPortName());
+ }
+ }
+ } else {
+ warning(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());
+ }
+ interfaceContract.setInterface(wsdlInterface);
+ model.setBindingInterfaceContract(interfaceContract);
+ }
+ }
+ }
+
+ 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 QName getArtifactType() {
+ return WebServiceConstants.BINDING_WS_QNAME;
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java
new file mode 100644
index 0000000000..46330c13f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+
+ 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/2004/08/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..678dfa1e2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#binding.ws,model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties
new file mode 100644
index 0000000000..2dfa5e6133
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/main/resources/binding-wsxml-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.
+#
+#
+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}
+WsdlBindingDoesNotMatch = The #wsdl.binding({0}) does not match with the WSDL Definitions
+WsdlServiceDoesNotMatch = The #wsdl.service({0}) does not match with the WSDL Definitions
+WsdlPortTypeDoesNotMatch = The #wsdl.port({0}) does not match with the WSDL Definitions
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite
new file mode 100644
index 0000000000..558365b05e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite
new file mode 100644
index 0000000000..1952d83755
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..6d36198124
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite b/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite
new file mode 100644
index 0000000000..036b5f0d1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/builder/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..df432f10c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA Model Builders
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397097203
+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.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.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.definitions;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",
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/builder/pom.xml
new file mode 100644
index 0000000000..cad5e5ff18
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java
new file mode 100644
index 0000000000..111680b2b4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java
@@ -0,0 +1,703 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactory;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+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.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.SCABinding;
+import org.apache.tuscany.sca.assembly.SCABindingFactory;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+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.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+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.PolicySubject;
+import org.w3c.dom.Document;
+
+/**
+ * Base class for Builder implementations
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class BaseBuilderImpl implements CompositeBuilder {
+ protected static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ protected static final String BINDING_SCA = "binding.sca";
+ protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ protected AssemblyFactory assemblyFactory;
+ protected SCABindingFactory scaBindingFactory;
+ protected InterfaceContractMapper interfaceContractMapper;
+ protected DocumentBuilderFactory documentBuilderFactory;
+ protected TransformerFactory transformerFactory;
+ protected BuilderExtensionPoint builders;
+
+ protected BaseBuilderImpl(BuilderExtensionPoint builders,
+ AssemblyFactory assemblyFactory,
+ SCABindingFactory scaBindingFactory,
+ DocumentBuilderFactory documentBuilderFactory,
+ TransformerFactory transformerFactory,
+ InterfaceContractMapper interfaceContractMapper) {
+ this.builders = builders;
+ this.assemblyFactory = assemblyFactory;
+ this.scaBindingFactory = scaBindingFactory;
+ this.documentBuilderFactory = documentBuilderFactory;
+ this.transformerFactory = transformerFactory;
+ this.interfaceContractMapper = interfaceContractMapper;
+ }
+
+ /**
+ * Construct a builder from the extension point registry
+ * @param registry
+ */
+ protected BaseBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factoryExtensionPoint.getFactory(AssemblyFactory.class);
+ this.scaBindingFactory = factoryExtensionPoint.getFactory(SCABindingFactory.class);
+ this.documentBuilderFactory = factoryExtensionPoint.getFactory(DocumentBuilderFactory.class);
+ this.transformerFactory = factoryExtensionPoint.getFactory(TransformerFactory.class);
+ this.interfaceContractMapper =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(InterfaceContractMapper.class);
+ }
+
+ /**
+ * Report a warning.
+ *
+ * @param monitor
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.ASSEMBLY_VALIDATION,
+ Severity.WARNING,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a error.
+ *
+ * @param 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.ASSEMBLY_VALIDATION,
+ Severity.ERROR,
+ model,
+ message,
+ messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Report a exception.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ protected void error(Monitor monitor, String message, Object model, Exception ex) {
+ if (monitor != null) {
+ Problem problem = null;
+ problem =
+ monitor.createProblem(this.getClass().getName(),
+ Messages.ASSEMBLY_VALIDATION,
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
+ }
+
+ /**
+ * Index components inside a composite
+ *
+ * @param composite
+ * @param componentServices
+
+ */
+ protected void indexComponents(Composite composite, Map<String, Component> components) {
+ for (Component component : composite.getComponents()) {
+ // Index components by name
+ components.put(component.getName(), component);
+ }
+ }
+
+ /**
+ * Index services inside a composite
+ *
+ * @param composite
+ * @param componentServices
+ */
+ protected void indexServices(Composite composite, Map<String, ComponentService> componentServices) {
+
+ for (Component component : composite.getComponents()) {
+
+ ComponentService nonCallbackService = null;
+ int nonCallbackServiceCount = 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 there are
+ if (!componentService.isForCallback()) {
+
+ if (nonCallbackServiceCount == 0) {
+ nonCallbackService = componentService;
+ }
+ nonCallbackServiceCount++;
+ }
+ }
+ if (nonCallbackServiceCount == 1) {
+ // If we have a single non callback service, index it by
+ // component name as well
+ componentServices.put(component.getName(), nonCallbackService);
+ }
+ }
+ }
+
+ /**
+ * Index components, services and references inside a composite.
+ * @param composite
+ * @param components
+ * @param componentServices
+ * @param componentReferences
+ */
+ 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);
+
+ // TODO - EPR - $promoted$ no longer used but it doesn't do any harm here
+ boolean promotedService = false;
+ if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) {
+ promotedService = true;
+ }
+
+ // count how many non-callback, non-promoted services there are
+ // if there is only one the component name also acts as the service name
+ if ((!componentService.isForCallback()) && (!promotedService)) {
+
+ // 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);
+ }
+ }
+ }
+
+ protected void indexComponentPropertiesServicesAndReferences(Component component,
+ Map<String, ComponentService> componentServices,
+ Map<String, ComponentReference> componentReferences,
+ Map<String, ComponentProperty> componentProperties,
+ Monitor monitor) {
+ for (ComponentService componentService : component.getServices()) {
+ if (componentServices.containsKey(componentService.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateComponentServiceName", component, component.getName(), componentService
+ .getName());
+ } else {
+ componentServices.put(componentService.getName(), componentService);
+ }
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (componentReferences.containsKey(componentReference.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateComponentReferenceName", component, component.getName(), componentReference
+ .getName());
+ } else {
+ componentReferences.put(componentReference.getName(), componentReference);
+ }
+ }
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ if (componentProperties.containsKey(componentProperty.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateComponentPropertyName", component, component.getName(), componentProperty
+ .getName());
+ } else {
+ componentProperties.put(componentProperty.getName(), componentProperty);
+ }
+ }
+
+ }
+
+ protected void indexImplementationPropertiesServicesAndReferences(Component component,
+ Map<String, Service> services,
+ Map<String, Reference> references,
+ Map<String, Property> properties,
+ Monitor monitor) {
+ // First check that the component has a resolved implementation
+ Implementation implementation = component.getImplementation();
+ if (implementation == null) {
+ // A component must have an implementation
+ error(monitor, "NoComponentImplementation", component, component.getName());
+
+ } else if (implementation.isUnresolved()) {
+
+ // The implementation must be fully resolved
+ error(monitor, "UnresolvedComponentImplementation", component, component.getName(), implementation.getURI());
+
+ } else {
+
+ // Index properties, services and references, also check for
+ // duplicates
+ for (Property property : implementation.getProperties()) {
+ if (properties.containsKey(property.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateImplementationPropertyName", component, component.getName(), property
+ .getName());
+ } else {
+ properties.put(property.getName(), property);
+ }
+ }
+ for (Service service : implementation.getServices()) {
+ if (services.containsKey(service.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateImplementationServiceName", component, component.getName(), service
+ .getName());
+ } else {
+ services.put(service.getName(), service);
+ }
+ }
+ for (Reference reference : implementation.getReferences()) {
+ if (references.containsKey(reference.getName())) {
+ // [MJE 13/05/2009] Changed to "error" since allowing these violates the OASIS spec
+ error(monitor, "DuplicateImplementationReferenceName", component, component.getName(), reference
+ .getName());
+ } else {
+ references.put(reference.getName(), reference);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Reconcile component properties and the properties defined by the
+ * component type.
+ *
+ * @param component
+ * @param properties
+ * @param componentProperties
+ * @param problems
+ */
+ protected void reconcileProperties(Component component,
+ Map<String, Property> properties,
+ Map<String, ComponentProperty> componentProperties,
+ Monitor monitor) {
+
+ // Connect component properties to their properties
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ Property property = properties.get(componentProperty.getName());
+ if (property != null) {
+ componentProperty.setProperty(property);
+ } else {
+ error(monitor, "PropertyNotFound", component, component.getName(), componentProperty.getName());
+ }
+ }
+
+ // Create component properties for all properties
+ if (component.getImplementation() != null) {
+ for (Property property : component.getImplementation().getProperties()) {
+ if (!componentProperties.containsKey(property.getName())) {
+ ComponentProperty 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);
+ }
+ }
+ }
+
+ // Reconcile component properties and their properties
+ for (ComponentProperty componentProperty : component.getProperties()) {
+ Property property = componentProperty.getProperty();
+ if (property != null) {
+
+ // Check that a component property does not override the
+ // mustSupply attribute
+ if (!property.isMustSupply() && componentProperty.isMustSupply()) {
+ warning(monitor,
+ "PropertyMustSupplyIncompatible",
+ component,
+ component.getName(),
+ componentProperty.getName());
+ }
+
+ // Default to the mustSupply attribute specified on the property
+ if (!componentProperty.isMustSupply())
+ componentProperty.setMustSupply(property.isMustSupply());
+
+ // Default to the value specified on the component type property
+ if (!isPropertyValueSet(componentProperty)) {
+ componentProperty.setValue(property.getValue());
+ }
+
+ // Override the property value for the composite
+ if (component.getImplementation() instanceof Composite) {
+ property.setValue(componentProperty.getValue());
+ }
+
+ // Check that a value is supplied
+ if (!isPropertyValueSet(componentProperty) && property.isMustSupply()) {
+ error(monitor, "PropertyMustSupplyNull", component, component.getName(), componentProperty.getName());
+ }
+
+ // Check that a component property does not override the
+ // many attribute
+ if (!property.isMany() && componentProperty.isMany()) {
+ warning(monitor, "PropertyOverrideManyAttribute", component, component.getName(), componentProperty.getName());
+ }
+
+ // Default to the many attribute defined on the property
+ componentProperty.setMany(property.isMany());
+
+ // Default to the type and element defined on the property
+ if (componentProperty.getXSDType() == null) {
+ componentProperty.setXSDType(property.getXSDType());
+ }
+ if (componentProperty.getXSDElement() == null) {
+ componentProperty.setXSDElement(property.getXSDElement());
+ }
+
+ // Check that a type or element are specified
+ if (componentProperty.getXSDElement() == null && componentProperty.getXSDType() == null) {
+ warning(monitor, "NoTypeForComponentProperty", component, component.getName(), componentProperty.getName());
+ }
+ }
+ }
+ }
+
+ /**
+ * 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.getFirstChild() == null) {
+ return false;
+ }
+
+ if (value.getFirstChild().getChildNodes().getLength() == 0) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Reconcile component references with the references defined on the
+ * component type.
+ *
+ * @param component
+ * @param references
+ * @param componentReferences
+ * @param monitor
+ */
+ protected void reconcileReferences(Component component,
+ Map<String, Reference> references,
+ Map<String, ComponentReference> componentReferences,
+ Monitor monitor) {
+
+ // Connect each component reference to the corresponding reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (componentReference.getReference() != null || componentReference.isForCallback()) {
+ continue;
+ }
+ Reference reference = references.get(componentReference.getName());
+ if (reference != null) {
+ componentReference.setReference(reference);
+ } else {
+ if (!componentReference.getName().startsWith("$self$.")) {
+ error(monitor, "ReferenceNotFound", component, component.getName(), componentReference.getName());
+ }
+ }
+ }
+
+ // Create a Component reference for each reference for which there is no declared Component reference
+ if (component.getImplementation() != null) {
+ for (Reference reference : component.getImplementation().getReferences()) {
+ if (!componentReferences.containsKey(reference.getName())) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setForCallback(reference.isForCallback());
+ componentReference.setName(reference.getName());
+ componentReference.setReference(reference);
+ component.getReferences().add(componentReference);
+ }
+ }
+ }
+
+ // Reconcile each component reference with its reference
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference reference = componentReference.getReference();
+ if (reference != null) {
+ // Reconcile multiplicity
+ if (componentReference.getMultiplicity() != null) {
+ if (!ReferenceConfigurationUtil.isValidMultiplicityOverride(reference.getMultiplicity(),
+ componentReference.getMultiplicity())) {
+ error(monitor,
+ "ReferenceIncompatibleMultiplicity",
+ component,
+ component.getName(),
+ componentReference.getName());
+ }
+ } else {
+ componentReference.setMultiplicity(reference.getMultiplicity());
+ }
+
+ // Reconcile interface
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ if (componentReference.getInterfaceContract() != null) {
+ if (interfaceContract != null && !componentReference.getInterfaceContract().equals(reference
+ .getInterfaceContract())) {
+ if (!interfaceContractMapper.isCompatible(interfaceContract, componentReference
+ .getInterfaceContract())) {
+ error(monitor,
+ "ReferenceIncompatibleComponentInterface",
+ component,
+ component.getName(),
+ componentReference.getName());
+ }
+ }
+ } else {
+ componentReference.setInterfaceContract(interfaceContract);
+ }
+
+ // Reconcile bindings
+ if (componentReference.getBindings().isEmpty()) {
+ componentReference.getBindings().addAll(reference.getBindings());
+ }
+
+ // Reconcile callback bindings
+ if (componentReference.getCallback() == null) {
+ componentReference.setCallback(reference.getCallback());
+ if (componentReference.getCallback() == null) {
+ // Create an empty callback to avoid null check
+ componentReference.setCallback(assemblyFactory.createCallback());
+ }
+
+ } else if (componentReference.getCallback().getBindings().isEmpty() && reference.getCallback() != null) {
+ componentReference.getCallback().getBindings().addAll(reference.getCallback().getBindings());
+ }
+
+ // Propagate autowire setting from the component
+ if (componentReference.getAutowire() == null) {
+ componentReference.setAutowire(component.getAutowire());
+ }
+
+ // Reconcile targets
+ if (componentReference.getTargets().isEmpty()) {
+ componentReference.getTargets().addAll(reference.getTargets());
+ }
+ }
+ }
+ }
+
+ /**
+ * Reconcile component services and services defined on the component type.
+ *
+ * @param component
+ * @param services
+ * @param componentServices
+ * @param monitor
+ */
+ protected void reconcileServices(Component component,
+ Map<String, Service> services,
+ Map<String, ComponentService> componentServices,
+ Monitor monitor) {
+
+ // Connect each component service to the corresponding service
+ for (ComponentService componentService : component.getServices()) {
+ if (componentService.getService() != null || componentService.isForCallback()) {
+ continue;
+ }
+ Service service = services.get(componentService.getName());
+ if (service != null) {
+ componentService.setService(service);
+ } else {
+ warning(monitor, "ServiceNotFoundForComponentService", component, component.getName(), componentService
+ .getName());
+ }
+ }
+
+ // Create a component service for each service
+ if (component.getImplementation() != null) {
+ for (Service service : component.getImplementation().getServices()) {
+ if (!componentServices.containsKey(service.getName())) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setForCallback(service.isForCallback());
+ String name = service.getName();
+ componentService.setName(name);
+ componentService.setService(service);
+ component.getServices().add(componentService);
+ componentServices.put(name, componentService);
+ }
+ }
+ }
+
+ //Reconcile each component service with its service
+ for (ComponentService componentService : component.getServices()) {
+ Service service = componentService.getService();
+ if (service != null) {
+ // Reconcile interface
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+ if (componentService.getInterfaceContract() != null) {
+ if (interfaceContract != null && !componentService.getInterfaceContract().equals(interfaceContract)) {
+ if (!interfaceContractMapper.isCompatible(componentService.getInterfaceContract(),
+ interfaceContract)) {
+ // MJE, 16/05/2009 - Upgraded from "warning" to "error" since this is a fatal problem - TUSCANY-3036
+ error(monitor,
+ "ServiceIncompatibleComponentInterface",
+ component,
+ component.getName(),
+ componentService.getName());
+ }
+ }
+ } else {
+ componentService.setInterfaceContract(interfaceContract);
+ }
+
+ // Reconcile bindings
+ if (componentService.getBindings().isEmpty()) {
+ componentService.getBindings().addAll(service.getBindings());
+ }
+
+ // Reconcile callback bindings
+ if (componentService.getCallback() == null) {
+ componentService.setCallback(service.getCallback());
+ if (componentService.getCallback() == null) {
+ // Create an empty callback to avoid null check
+ componentService.setCallback(assemblyFactory.createCallback());
+ }
+ } else if (componentService.getCallback().getBindings().isEmpty() && service.getCallback() != null) {
+ componentService.getCallback().getBindings().addAll(service.getCallback().getBindings());
+ }
+ }
+ }
+ }
+
+ protected void attachSCABinding(Contract contract, Definitions definitions) {
+ if (!contract.getBindings().isEmpty()) {
+ contract.setOverridingBindings(true);
+ // No need to set binding.sca
+ return;
+ }
+ contract.setOverridingBindings(false);
+
+ // Only add binding.sca for services
+ // FIXME: The latest OASIS spec only adds binding.sca to services
+ /*
+ if (!(contract instanceof Service)) {
+ return;
+ }
+ */
+ 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);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
new file mode 100644
index 0000000000..205a3157de
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentComponentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ // Process nested composite
+ configureBindingURIs((Composite)implementation, componentURI, 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;
+ if (binding.getURI() != null) {
+ bindingURI = new URI(binding.getURI());
+
+ // if the user has provided an absolute binding URI then use it
+ if (bindingURI.isAbsolute()) {
+ binding.setURI(bindingURI.toString());
+ return;
+ }
+ } else {
+ bindingURI = null;
+ }
+
+ 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;
+ if (componentURIString != null) {
+ componentURI = new URI(addSlashToPath(componentURIString));
+ } else {
+ componentURI = null;
+ }
+
+ // if the user has provided an absolute component URI then use it
+ if (componentURI != null && componentURI.isAbsolute()) {
+ binding.setURI(constructBindingURI(null,
+ componentURI,
+ bindingURI,
+ serviceName,
+ includeBindingName,
+ bindingName));
+ return;
+ }
+
+ // calculate the base URI
+ URI baseURI = null;
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
new file mode 100644
index 0000000000..431d21179c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
@@ -0,0 +1,1244 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.InputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+
+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.sax.SAXSource;
+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.ImplementationBuilder;
+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.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.ExtensionType;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+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/200903";
+ protected static final String BINDING_SCA = "binding.sca";
+ protected static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
+
+ private CompositeComponentTypeBuilderImpl componentTypeBuilder;
+ private AssemblyFactory assemblyFactory;
+ private SCABindingFactory scaBindingFactory;
+ private DocumentBuilderFactory documentBuilderFactory;
+ protected TransformerFactory transformerFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+ private BuilderExtensionPoint builders;
+
+ 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);
+
+ builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ }
+
+ public void setComponentTypeBuilder(CompositeComponentTypeBuilderImpl componentTypeBuilder) {
+ this.componentTypeBuilder = componentTypeBuilder;
+ }
+
+ /**
+ * Configure the component based on its component type using OASIS rules
+ *
+ * @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, monitor);
+
+ // configure services based on the calculated component type
+ configureReferences(component, monitor);
+ } 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, Monitor monitor) {
+
+ // 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(componentService, componentTypeService);
+
+ // add callback reference model objects
+ createCallbackReference(component, componentService);
+
+ // intents - done later in CompositePolicyBuilder - discuss with RF
+ //calculateIntents(componentService,
+ // componentTypeService);
+
+ // policy sets - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePolicySets(componentService,
+ // componentTypeService);
+
+ }
+ }
+
+ /**
+ * 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, Monitor monitor) {
+
+ // 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);
+
+ // intents - done later in CompositePolicyBuilder - discuss with RF
+ //calculateIntents(componentService,
+ // componentTypeService);
+
+ // policy sets - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePolicySets(componentService,
+ // componentTypeService);
+
+ // Propagate autowire setting from the component down the structural
+ // hierarchy
+ if (componentReference.getAutowire() == null) {
+ componentReference.setAutowire(component.getAutowire());
+ }
+
+ // Reconcile targets copying then up the promotion hierarchy
+ if (componentReference.getTargets().isEmpty()) {
+ componentReference.getTargets().addAll(componentTypeReference.getTargets());
+ }
+
+ }
+ }
+
+ /**
+ * 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());
+ }
+
+ }
+ }
+
+ 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().toString(),
+ componentTypeProperty.getXSDElement().toString());
+ }
+
+ if ( componentProperty.getXSDType() != null &&
+ !componentProperty.getXSDType().equals(componentTypeProperty.getXSDType())){
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertXSDTypesDontMatch",
+ component.getName(),
+ componentProperty.getName(),
+ componentProperty.getXSDType().toString(),
+ componentTypeProperty.getXSDType().toString());
+ }
+ }
+ }
+
+ /**
+ * 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) {
+ // $<name>/...
+ int index = source.indexOf('/');
+ if (index == -1) {
+ // Tolerating $prop
+ source = source + "/";
+ index = source.length() - 1;
+ }
+ if (source.charAt(0) == '$') {
+ String name = source.substring(1, index);
+ Property sourceProp = null;
+ if (outerComponent != null) {
+ sourceProp = outerComponent.getProperty(name);
+ } else {
+ sourceProp = parentComposite.getProperty(name);
+ }
+ if (sourceProp == null) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceNotFound",
+ source,
+ componentProperty.getName(),
+ component.getName());
+ }
+
+ Document sourcePropValue = (Document)sourceProp.getValue();
+
+ try {
+ // FIXME: How to deal with namespaces?
+ Document node =
+ evaluateXPath(sourcePropValue,
+ componentProperty.getSourceXPathExpression(),
+ documentBuilderFactory);
+
+ if (node != null) {
+ componentProperty.setValue(node);
+ } else {
+ Monitor.warning(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyXpathExpressionReturnedNull",
+ component.getName(),
+ componentProperty.getName());
+ }
+ } catch (Exception ex) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceXpathInvalid",
+ source,
+ componentProperty.getName(),
+ component.getName(),
+ ex);
+ }
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertySourceValueInvalid",
+ source,
+ componentProperty.getName(),
+ component.getName());
+ }
+ }
+ }
+
+ /**
+ * If the property has a file attribute use this to retrieve the value from a
+ * local file
+
+ *
+ * @param parentCompoent the composite that contains the component
+ * @param component
+ */
+ private void processPropertyFileAttribute(Component component, ComponentProperty componentProperty, Monitor monitor) {
+ String file = componentProperty.getFile();
+ if (file != null) {
+ 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();
+
+ // TUSCANY-2377, Add a fake value element so it's consistent with
+ // the DOM tree loaded from inside SCDL
+ Element root = document.createElementNS(null, "value");
+ root.appendChild(document.getDocumentElement());
+ document.appendChild(root);
+ componentProperty.setValue(document);
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
+ } catch (Exception ex) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PropertyFileValueInvalid",
+ file,
+ componentProperty.getName(),
+ component.getName(),
+ ex);
+ }
+ }
+
+ }
+
+ /**
+ * 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;
+ }
+ }
+
+ /**
+ * Create a callback reference for a component service
+ *
+ * @param component
+ * @param service
+ */
+ private void createCallbackReference(Component component, ComponentService service) {
+
+ // 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());
+ 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());
+ // Set the promoted service
+ ComponentReference promotedReference = assemblyFactory.createComponentReference();
+ String promotedRefName =
+ ((CompositeService)implService).getPromotedComponent().getName() + "/"
+ + ((CompositeService)implService).getPromotedService().getName();
+ promotedReference.setName(promotedRefName);
+ promotedReference.setUnresolved(true);
+ implCompReference.getPromotedReferences().add(promotedReference);
+ 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());
+ 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
+ if (service.getCallback() != null && service.getCallback().getBindings().size() > 0) {
+ callbackReference.getBindings().addAll(service.getCallback().getBindings());
+ } else {
+ // otherwise create a default binding which
+ // will cause the EPR for this reference to be
+ // marked as EndpointReference.NOT_CONFIGURED
+ createSCABinding(callbackReference, null);
+
+ // TODO - should really use the forward binding here but
+ // awaiting OASIS decision on what's going to
+ // happen with callbacks
+ }
+ }
+ service.setCallbackReference(callbackReference);
+ }
+ }
+
+ /**
+ * Create a callback service for a component reference
+ *
+ * @param component
+ * @param service
+ */
+ private void createCallbackService(Component component, ComponentReference reference) {
+ if (reference.getInterfaceContract() != null && // can be null in unit tests
+ reference.getInterfaceContract().getCallbackInterface() != null) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setForCallback(true);
+ componentService.setName(reference.getName());
+ try {
+ InterfaceContract contract = (InterfaceContract)reference.getInterfaceContract().clone();
+ contract.setInterface(contract.getCallbackInterface());
+ contract.setCallbackInterface(null);
+ componentService.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);
+ // Set the promoted service
+ ComponentService promotedService = assemblyFactory.createComponentService();
+ promotedService.setName(((CompositeReference)implReference).getPromotedReferences().get(0)
+ .getName());
+ promotedService.setUnresolved(true);
+ promotedService.setForCallback(true);
+ implCompService.setPromotedService(promotedService);
+ 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
+ }
+ componentService.setService(implService);
+ }
+ component.getServices().add(componentService);
+
+ // configure bindings for the callback service
+ if (componentService.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
+ componentService.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);
+ componentService.getBindings().add(clonedBinding);
+ } catch (CloneNotSupportedException ex) {
+
+ }
+ }
+ } else {
+ // TODO - should use the binding resolved from the service but
+ // waiting for OASIS to decide what to do about callbacks
+ // create a default binding
+ createSCABinding(componentService, null);
+ }
+ }
+
+ reference.setCallbackService(componentService);
+ }
+ }
+
+ /**
+ * 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.getFirstChild() == null) {
+ return false;
+ }
+
+ if (value.getFirstChild().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.getFirstChild().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 = interfaceContractMapper.checkCompatibility(topInterfaceContract, bottomInterfaceContract, false, false);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ServiceIncompatibleComponentInterface",
+ component.getName(),
+ topContract.getName(),
+ incompatibilityReason);
+ }
+ }
+ }
+
+ /**
+ * 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 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 = interfaceContractMapper.checkCompatibility(bottomInterfaceContract, topInterfaceContract, false, false);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceIncompatibleComponentInterface",
+ component.getName(),
+ topContract.getName(),
+ incompatibilityReason);
+ }
+ }
+ }
+
+ /**
+ * Bindings from higher in the hierarchy take precedence
+ *
+ * @param componentService the top service
+ * @param componentTypeService the bottom service
+ */
+ private void calculateBindings(Service componentService, Service componentTypeService) {
+ // forward bindings
+ if (componentService.getBindings().isEmpty()) {
+ componentService.getBindings().addAll(componentTypeService.getBindings());
+ }
+
+ if (componentService.getBindings().isEmpty()) {
+ createSCABinding(componentService, null);
+ }
+
+ // 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());
+ }
+
+ }
+
+ /**
+ * 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());
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java
new file mode 100644
index 0000000000..c48d868105
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+ }
+ }
+ }
+ }
+
+ // build bindings recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ buildReferenceBindings((Composite)implementation, context);
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java
new file mode 100644
index 0000000000..aaa9cbe82c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.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.builder.impl;
+
+import java.util.List;
+
+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.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Implementation;
+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.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.monitor.Monitor;
+
+/**
+ * A composite builder that handles the creation of promoted composite services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder {
+ private AssemblyFactory assemblyFactory;
+
+ public ComponentReferencePromotionBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ }
+
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ configureNestedCompositeReferences(composite, context.getMonitor());
+ return composite;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.ComponentReferencePromotionBuilder";
+ }
+
+ /**
+ * Push down reference configuration into nested composites.
+ *
+ * @param composite
+ * @param problems
+ */
+ private void configureNestedCompositeReferences(Composite composite, Monitor monitor) {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ configureNestedCompositeReferences((Composite)implementation, monitor);
+ }
+ }
+
+ // Process component references declared on components in this composite
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ Reference implReference = componentReference.getReference();
+ if (implReference != null && implReference instanceof CompositeReference) {
+
+ // If the component reference is wired, it is a promotion override
+ if (!componentReference.getEndpointReferences().isEmpty()) {
+ componentReference.setPromotionOverride(true);
+ }
+
+ // If the component reference is a promotion override, override the
+ // configuration of the promoted reference
+ if (componentReference.isPromotionOverride()) {
+ CompositeReference compositeReference = (CompositeReference)implReference;
+ List<ComponentReference> promotedReferences =
+ ReferenceConfigurationUtil.getPromotedComponentReferences(compositeReference);
+ for (ComponentReference promotedReference : promotedReferences) {
+ ReferenceConfigurationUtil.reconcileReferenceBindings(componentReference,
+ promotedReference,
+ assemblyFactory,
+ monitor);
+ if (componentReference.getInterfaceContract() != null && // can be null in unit tests
+ componentReference.getInterfaceContract().getCallbackInterface() != null) {
+ SCABinding scaCallbackBinding =
+ promotedReference.getCallbackBinding(SCABinding.class);
+ if (promotedReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().clear();
+ } else {
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ }
+ if (scaCallbackBinding != null) {
+ promotedReference.getCallback().getBindings().add(scaCallbackBinding);
+ }
+ if (componentReference.getCallback() != null) {
+ promotedReference.getCallback().getBindings().addAll(componentReference
+ .getCallback().getBindings());
+ }
+ }
+ /* TODO - let endpoint references worry about target service
+ // Wire the promoted reference to the actual non-composite component services
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE) {
+ // promotedReference.getTargets().clear();
+ }
+ for (ComponentService target : componentReference.getTargets()) {
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ // Find the promoted component service
+ ComponentService componentService =
+ ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ if (componentService != null) {
+ promotedReference.getTargets().add(componentService);
+ }
+ } else {
+
+ // Wire to a non-composite target service
+ promotedReference.getTargets().add(target);
+ }
+ }
+ */
+ }
+ }
+ }
+ }
+ } else {
+ /* TODO - let endpoint references worry about target servicep
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Wire the component reference to the actual
+ // non-composite component services
+ List<ComponentService> targets = componentReference.getTargets();
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.getService() instanceof CompositeService) {
+
+ // Wire to the actual component service
+ // promoted by a composite service
+ CompositeService compositeService = (CompositeService)target.getService();
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null) {
+ targets.set(i, componentService);
+ }
+ }
+ }
+ }
+ */
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java
new file mode 100644
index 0000000000..9a74023504
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java
new file mode 100644
index 0000000000..148a3b5368
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
new file mode 100644
index 0000000000..75fda5880a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java
@@ -0,0 +1,528 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.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.IncompatibleInterfaceContractException;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+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/200903";
+ 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;
+
+ 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);
+ }
+
+ 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, monitor);
+
+ // references
+ calculateReferences(composite, components, componentReferences, monitor);
+
+ // 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,
+ Monitor monitor) {
+
+ // 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);
+
+ // promote intents - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePromotedIntents(compositeService, promotedComponentService);
+
+ // promote policy sets - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePromotedPolicySets(compositeService, promotedComponentService);
+ }
+ }
+
+ /**
+ * 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, Monitor monitor) {
+
+ // 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 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);
+
+ // promote intents - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePromotedIntents(compositeService, promotedComponentService);
+
+ // promote policy sets - done later in CompositePolicyBuilder - discuss with RF
+ // calculatePromotedPolicySets(compositeService, promotedComponentService);
+ }
+ }
+ }
+
+ /**
+ * 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 = interfaceContractMapper.checkCompatibility(topInterfaceContract, bottomInterfaceContract, false, false);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ServiceInterfaceNotSubSet",
+ topContract.getName(),
+ incompatibilityReason);
+ }
+ }
+ }
+
+ /**
+ * 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 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 = interfaceContractMapper.checkCompatibility(bottomInterfaceContract, topInterfaceContract, false, false);
+ } catch (IncompatibleInterfaceContractException ex){
+ isCompatible = false;
+ incompatibilityReason = ex.getMessage();
+ }
+ if (!isCompatible) {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "ReferenceInterfaceNotSubSet",
+ topContract.getName(),
+ incompatibilityReason);
+ }
+ }
+ }
+
+ /**
+ * 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
+ }
+ }
+ }
+ }
+
+} //end class
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java
new file mode 100644
index 0000000000..b4a897af54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 && merged.getAutowire() == Boolean.TRUE) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
new file mode 100644
index 0000000000..f36a702752
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java
@@ -0,0 +1,534 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Collections;
+import java.util.HashSet;
+import java.util.List;
+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.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+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.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.PolicyBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
+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 CompositePolicyBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
+ public CompositePolicyBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder";
+ }
+
+ public Composite build(Composite composite, BuilderContext context) throws CompositeBuilderException {
+ computePolicies(composite, context);
+ buildPolicies(composite, context);
+ return composite;
+ }
+
+ /**
+ * Inherit the intents and policySets from the list of models
+ * @param intents
+ * @param policySets
+ * @param models
+ */
+ private void inherit(PolicySubject policySubject, Object... models) {
+ for (Object model : models) {
+ if (model instanceof PolicySubject) {
+ PolicySubject subject = (PolicySubject)model;
+ // FIXME: We should ignore the mutually exclusive intents from different levels
+ policySubject.getRequiredIntents().addAll(subject.getRequiredIntents());
+ policySubject.getPolicySets().addAll(subject.getPolicySets());
+ }
+ }
+ }
+
+ /**
+ * 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)) {
+ error(context.getMonitor(), "MutuallyExclusiveIntents", new Object[] {subject1, subject2}, i1, i2);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private 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);
+ 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)) {
+ error(context.getMonitor(), "MutuallyExclusiveIntents", subject, i1, i2);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Inherit the policySets and intents from the implementation hierarchy
+ * @param subject
+ * @param composite
+ * @param component
+ * @param service
+ */
+ private void inheritFromService(PolicySubject subject, Composite composite, Component component, Service service) {
+ if (service == null) {
+ return;
+ }
+ if (service instanceof ComponentService) {
+ // component!=null
+ if (component.getImplementation() instanceof Composite) {
+ composite = (Composite)component.getImplementation();
+ }
+ inheritFromService(subject, composite, component, ((ComponentService)service).getService());
+ // Component service also inherits the intents/policySets from composite/component
+ inherit(subject, composite, component);
+ } else if (service instanceof CompositeService) {
+ // composite!=null, component is not used
+ CompositeService compositeService = (CompositeService)service;
+ // Handle the promoted component service
+ inheritFromService(subject, composite, compositeService.getPromotedComponent(), compositeService
+ .getPromotedService());
+ }
+ // For atomic service, the composite is not used
+ inherit(subject, component.getImplementation(), service);
+ }
+
+ /**
+ * Inherit the policySets and intents from the implementation hierarchy
+ * @param subject
+ * @param composite
+ * @param component
+ * @param reference
+ */
+ private void inheritFromReference(PolicySubject subject,
+ Composite composite,
+ Component component,
+ Reference reference) {
+ if (reference == null) {
+ return;
+ }
+ if (reference instanceof ComponentReference) {
+ // component!=null
+ if (component.getImplementation() instanceof Composite) {
+ composite = (Composite)component.getImplementation();
+ }
+ inheritFromReference(subject, composite, component, ((ComponentReference)reference).getReference());
+ } else if (reference instanceof CompositeReference) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ for (int i = 0, n = compositeReference.getPromotedReferences().size(); i < n; i++) {
+ inheritFromReference(subject,
+ composite,
+ compositeReference.getPromotedComponents().get(i),
+ compositeReference.getPromotedReferences().get(i));
+ }
+ }
+ // Inherit from the componentType/reference
+ inherit(subject, component.getImplementation(), reference);
+ }
+
+ /**
+ * Check if two names are equal
+ * @param name1
+ * @param name2
+ * @return
+ */
+ private boolean isEqual(String name1, String name2) {
+ if (name1 == name2) {
+ return true;
+ }
+ if (name1 != null) {
+ return name1.equals(name2);
+ } else {
+ return name2.equals(name1);
+ }
+ }
+
+ private 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;
+ }
+
+ private 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 {
+ warning(context.getMonitor(), "IntentNotFound", 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;
+ }
+ }
+
+ // Remove the intents whose @contraints do not include the current element
+ // 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());
+ }
+ }
+
+ // Replace qualifiable intents with the default qualified intent
+ copy = new HashSet<Intent>(intents);
+ for (Intent i : copy) {
+ if (i.getDefaultQualifiedIntent() != null) {
+ intents.remove(i);
+ intents.add(i.getDefaultQualifiedIntent());
+ }
+ }
+
+ subject.getRequiredIntents().clear();
+ subject.getRequiredIntents().addAll(intents);
+
+ 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(), "PolicySetNotFound", subject, policySet);
+ }
+ }
+ }
+
+ for (Intent intent : subject.getRequiredIntents()) {
+ loop: for (PolicySet ps : definitions.getPolicySets()) {
+ // FIXME: We will have to check the policy references and intentMap too
+ // as well as the appliesTo
+ if (ps.getProvidedIntents().contains(intent)) {
+ policySets.add(ps);
+ break;
+ }
+ for (IntentMap map : ps.getIntentMaps()) {
+ for (Qualifier q : map.getQualifiers()) {
+ if (intent.equals(q.getIntent())) {
+ policySets.add(ps);
+ break loop;
+ }
+ }
+ }
+ }
+ }
+
+ subject.getPolicySets().clear();
+ subject.getPolicySets().addAll(policySets);
+
+ }
+
+ protected void computePolicies(Composite composite, BuilderContext context) {
+ resolveAndCheck(composite, context);
+
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ checkMutualExclusion(compositeService, compositeService.getPromotedService(), context);
+ }
+
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ for (Reference promoted : compositeReference.getPromotedReferences()) {
+ checkMutualExclusion(compositeReference, promoted, context);
+ }
+ }
+
+ // compute policies recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ resolveAndCheck(component, context);
+
+ // Check component against implementation
+ checkMutualExclusion(component, component.getImplementation(), context);
+
+ for (ComponentService componentService : component.getServices()) {
+ resolveAndCheck(componentService, context);
+ resolveAndCheck(componentService.getService(), context);
+
+ // Check component/service against componentType/service
+ checkMutualExclusion(componentService, componentService.getService(), context);
+
+ if (componentService.getInterfaceContract() != null && componentService.getService() != null) {
+ resolveAndCheck(componentService.getInterfaceContract().getInterface(), context);
+ resolveAndCheck(componentService.getService().getInterfaceContract().getInterface(), context);
+
+ checkMutualExclusion(componentService.getInterfaceContract().getInterface(), componentService
+ .getService().getInterfaceContract().getInterface(), context);
+
+ resolveAndCheck(componentService.getInterfaceContract().getCallbackInterface(), context);
+ resolveAndCheck(componentService.getService().getInterfaceContract().getCallbackInterface(),
+ context);
+
+ checkMutualExclusion(componentService.getInterfaceContract().getCallbackInterface(),
+ componentService.getService().getInterfaceContract().getCallbackInterface(),
+ context);
+ }
+
+ for (Endpoint ep : componentService.getEndpoints()) {
+ // Inherit from the componentType.service.interface
+ if (componentService.getService() != null && componentService.getService().getInterfaceContract() != null) {
+ inherit(ep, componentService.getService().getInterfaceContract().getInterface());
+ }
+ if (componentService.getInterfaceContract() != null) {
+ // Inherit from the component.service.interface
+ inherit(ep, componentService.getInterfaceContract().getInterface());
+ }
+ // Inherit from the componentType/service
+ inheritFromService(ep, composite, component, componentService.getService());
+ // Find the corresponding binding in the componentType and inherit the intents/policySets
+ if (componentService.getService() != null) {
+ for (Binding binding : componentService.getService().getBindings()) {
+ resolveAndCheck((PolicySubject)binding, context);
+ if (isEqual(ep.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) {
+ checkMutualExclusion((PolicySubject)ep.getBinding(), (PolicySubject)binding, context);
+ // Inherit from componentType.service.binding
+ inherit(ep, binding);
+ break;
+ }
+ }
+ }
+ // Inherit from composite/component/service
+ inheritFromService(ep, composite, ep.getComponent(), ep.getService());
+ // Inherit from binding
+ inherit(ep, ep.getBinding());
+
+ // Replace profile intents with their required intents
+ // Remove the intents whose @contraints do not include the current element
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualied intent
+ resolveAndNormalize(ep, context);
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ resolveAndCheck(componentReference, context);
+ resolveAndCheck(componentReference.getReference(), context);
+
+ // Check component/reference against componentType/reference
+ checkMutualExclusion(componentReference, componentReference.getReference(), context);
+
+ if (componentReference.getInterfaceContract() != null && componentReference.getReference() != null) {
+ resolveAndCheck(componentReference.getInterfaceContract().getInterface(), context);
+ resolveAndCheck(componentReference.getReference().getInterfaceContract().getInterface(), context);
+
+ checkMutualExclusion(componentReference.getInterfaceContract().getInterface(), componentReference
+ .getReference().getInterfaceContract().getInterface(), context);
+
+ resolveAndCheck(componentReference.getInterfaceContract().getCallbackInterface(), context);
+ resolveAndCheck(componentReference.getReference().getInterfaceContract().getCallbackInterface(),
+ context);
+
+ checkMutualExclusion(componentReference.getInterfaceContract().getCallbackInterface(),
+ componentReference.getReference().getInterfaceContract()
+ .getCallbackInterface(),
+ context);
+ }
+
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ // Inherit from the componentType.reference.interface
+ if (componentReference.getReference() != null && componentReference.getReference()
+ .getInterfaceContract() != null) {
+ inherit(epr, componentReference.getReference().getInterfaceContract().getInterface());
+ }
+ // Inherit from the component.reference.interface
+ if (componentReference.getInterfaceContract() != null) {
+ inherit(epr, componentReference.getInterfaceContract().getInterface());
+ }
+ // Inherit from the componentType/reference
+ inheritFromReference(epr, composite, component, componentReference.getReference());
+ // Find the corresponding binding in the componentType and inherit the intents/policySets
+ if (componentReference.getReference() != null) {
+ for (Binding binding : componentReference.getReference().getBindings()) {
+ if (epr.getBinding() != null && isEqual(epr.getBinding().getName(), binding.getName())
+ && (binding instanceof PolicySubject)) {
+ resolveAndCheck((PolicySubject)binding, context);
+ checkMutualExclusion((PolicySubject)epr.getBinding(), (PolicySubject)binding, context);
+ // Inherit from componentType.reference.binding
+ inherit(epr, binding);
+ break;
+ }
+ }
+ }
+ // Inherit from composite/component/reference/binding
+ inheritFromReference(epr, composite, epr.getComponent(), epr.getReference());
+ inherit(epr, epr.getBinding());
+
+ // Replace profile intents with their required intents
+ // Remove the intents whose @contraints do not include the current element
+ // Replace unqualified intents if there is a qualified intent in the list
+ // Replace qualifiable intents with the default qualied intent
+ resolveAndNormalize(epr, context);
+ }
+ }
+
+ if (implementation instanceof Composite) {
+ inherit(implementation, component, composite);
+ computePolicies((Composite)implementation, context);
+ } else {
+ resolveAndCheck(implementation, context);
+ if (implementation != null) {
+ inherit(implementation, component, composite);
+ }
+ }
+ }
+
+ }
+
+ private 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 void buildPolicies(Composite composite, BuilderContext context) {
+
+ // compute 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()) {
+ for (QName policyType : getPolicyNames(ep)) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(ep, context);
+ }
+ }
+ }
+ }
+
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ for (QName policyType : getPolicyNames(epr)) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(epr, context);
+ }
+ }
+ }
+ }
+
+ Implementation implementation = component.getImplementation();
+ if (implementation != null) {
+ for (QName policyType : getPolicyNames(implementation)) {
+ PolicyBuilder builder = builders.getPolicyBuilder(policyType);
+ if (builder != null) {
+ builder.build(component, implementation, context);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java
new file mode 100644
index 0000000000..6b181db0c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.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.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 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,
+ null,
+ "[JCA100006] JAX-WS client-side asynchronous pooling and callback methods are not allowed in service interfaces",
+ service,
+ service.getName());
+ }
+ }
+
+
+
+
+ /* change to finding the promoted component and service
+ * when the wire is created as storing them here leads to
+ * the wrong URI being calculated
+ Component endpointComponent = component;
+ ComponentService endpointService = service;
+
+ // TODO - EPR - We maintain all endpoints at the right level now
+ // but endpoints for promoting services must point down
+ // to the services they promote.
+ if (service.getService() instanceof CompositeService) {
+ CompositeService compositeService = (CompositeService)service.getService();
+ endpointService = ServiceConfigurationUtil.getPromotedComponentService(compositeService);
+ endpointComponent = ServiceConfigurationUtil.getPromotedComponent(compositeService);
+ } // end if
+ */
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
new file mode 100644
index 0000000000..b1cc873914
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
@@ -0,0 +1,839 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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;
+
+/**
+ * Creates endpoint reference models.
+ */
+public class EndpointReferenceBuilderImpl {
+
+ private AssemblyFactory assemblyFactory;
+ private InterfaceContractMapper interfaceContractMapper;
+
+ 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);
+ }
+
+ /**
+ * Create endpoint references for all component references.
+ *
+ * @param composite
+ */
+ public Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ Monitor monitor = context.getMonitor();
+
+ // process component services
+ processComponentReferences(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
+ } // end for
+
+ // Validate that references are wired or promoted, according
+ // to their multiplicity
+ validateReferenceMultiplicity(composite, component, monitor);
+
+ } finally {
+ monitor.popContext();
+ }
+ } // end for
+
+ } finally {
+ monitor.popContext();
+ }
+
+ } // end method processCompoenntReferences
+
+ 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);
+
+ // TODO - EPR - $promoted$ no longer used but it doesn't do any
+ // harm here
+ boolean promotedService = false;
+ if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) {
+ promotedService = true;
+ }
+
+ // count how many non-callback, non-promoted services there are
+ // if there is only one the component name also acts as the
+ // service name
+ if ((!componentService.isForCallback()) && (!promotedService)) {
+
+ // 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
+ .isCompatible(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 (reference.getAutowire() == Boolean.TRUE && 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.isCompatible(reference
+ .getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.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.isCompatible(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.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.setRemote(true);
+ endpointRef.setStatus(EndpointReference.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.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.setRemote(true);
+ endpointRef.setStatus(EndpointReference.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.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.RESOLVED_BINDING);
+ }
+ endpointRef.setRemote(true);
+ 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.isCompatible(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.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.setRemote(true);
+ endpointRef.setStatus(EndpointReference.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.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.setRemote(true);
+ endpointRef.setStatus(EndpointReference.RESOLVED_BINDING);
+ reference.getEndpointReferences().add(endpointRef);
+ } // end if
+ }
+ }
+
+ monitor.popContext();
+
+ } // end method
+
+ private void validateReferenceMultiplicity(Composite composite, Component component, Monitor monitor) {
+ for (ComponentReference componentReference : component.getReferences()) {
+ if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(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 (componentReference.getAutowire() == Boolean.TRUE) {
+ break;
+ }
+
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "TooManyReferenceTargets",
+ componentReference.getName());
+ }
+ }
+ }
+
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java
new file mode 100644
index 0000000000..206afb98da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.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.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;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+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 EndpointBuilderImpl endpointBuilder;
+ private EndpointReferenceBuilderImpl endpointReferenceBuilder;
+ private ComponentReferencePromotionBuilderImpl componentReferencePromotionBuilder;
+
+ 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);
+ endpointBuilder = new EndpointBuilderImpl(registry);
+ endpointReferenceBuilder = new EndpointReferenceBuilderImpl(registry);
+ componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(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 {
+ Monitor monitor = context.getMonitor();
+ 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);
+
+ // need to apply policy external attachment
+ 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);
+
+ // create the runtime model by updating the static model we have just
+ // created. This involves things like creating
+ // component URIs
+ // binding URIs
+ // binding specific build processing
+ // callback references - currently done in static pass
+ // callback services - currently done in static pass
+ // Endpoints
+ // Endoint References
+ // Policies
+ // TODO - called here at the moment but we could have a separate build phase
+ // to call these. Also we need to re-org these builders
+ composite = bindingURIBuilder.build(composite, context);
+ composite = componentServiceBindingBuilder.build(composite, context); // binding specific build
+ composite = componentReferenceBindingBuilder.build(composite, context); // binding specific build
+ endpointBuilder.build(composite, context);
+ endpointReferenceBuilder.build(composite, context);
+ composite = componentReferencePromotionBuilder.build(composite, context); // move into the static build?
+ composite = compositePolicyBuilder.build(composite, context); // the rest of the policy processing?
+
+ // 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
new file mode 100644
index 0000000000..cbbf54b330
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
@@ -0,0 +1,379 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 javax.xml.XMLConstants.DEFAULT_NS_PREFIX;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE;
+import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+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.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+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;
+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, add the policySets attribute
+ * to the subject element. Then reload the patched DOM into a Composite model again.
+ *
+ * @version $Rev$ $Date$
+ */
+public class PolicyAttachmentBuilderImpl implements CompositeBuilder {
+ private StAXHelper staxHelper;
+ private DOMHelper domHelper;
+ private ExtensionPointRegistry registry;
+ private 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 {
+ if (definitions == null || definitions.getPolicySets().isEmpty()) {
+ return composite;
+ }
+ // Recursively apply the xpath against the composites referenced by <implementation.composite>
+ for (Component component : composite.getComponents()) {
+ Implementation impl = component.getImplementation();
+ if (impl instanceof Composite) {
+ Composite patched = applyXPath((Composite)impl, definitions, monitor);
+ if (patched != impl) {
+ component.setImplementation(patched);
+ }
+ }
+ }
+ Document document = null;
+
+ for (PolicySet ps : definitions.getPolicySets()) {
+ // First calculate the applicable nodes
+ Set<Node> applicableNodes = null;
+ /*
+ XPathExpression appliesTo = ps.getAppliesToXPathExpression();
+ if (appliesTo != null) {
+ applicableNodes = new HashSet<Node>();
+ NodeList nodes = (NodeList)appliesTo.evaluate(document, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ applicableNodes.add(nodes.item(i));
+ }
+ }
+ */
+ XPathExpression exp = ps.getAttachToXPathExpression();
+ if (exp != null) {
+ if (document == null) {
+ document = saveAsDOM(composite);
+ }
+ NodeList nodes = (NodeList)exp.evaluate(document, XPathConstants.NODESET);
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (applicableNodes == null || applicableNodes.contains(node)) {
+ // The node can be a component, service, reference or binding
+ String index = getStructuralURI(node);
+ PolicySubject subject = lookup(composite, index);
+ if (subject != null) {
+ subject.getPolicySets().add(ps);
+ }
+ }
+ }
+ }
+ }
+
+ return composite;
+ }
+
+ private 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());
+ 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");
+
+ private 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 {
+ 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()";
+ }
+ }
+ }
+ return null;
+ }
+
+ private Binding getBinding(Contract contract, String name) {
+ for (Binding binding : contract.getBindings()) {
+ if (name.equals(binding.getName())) {
+ return binding;
+ }
+ }
+ return null;
+ }
+
+ private PolicySubject lookup(Composite composite, String structuralURI) {
+ if (structuralURI == null) {
+ return null;
+ }
+ int index = structuralURI.indexOf('#');
+ String componentURI = structuralURI;
+ String service = null;
+ String reference = null;
+ String binding = null;
+ 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, index);
+ 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;
+ }
+ }
+ }
+ }
+ for (Component component : composite.getComponents()) {
+ if (component.getURI().equals(componentURI)) {
+ if (service != null) {
+ ComponentService componentService = component.getService(service);
+ 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;
+ }
+
+ /**
+ * Attach the policySet to the given DOM node
+ * @param node The DOM node (should be an element)
+ * @param policySet The policy set to be attached
+ * @return true if the element is changed, false if the element already contains the same policy set
+ * and no change is made
+ */
+ private boolean attach(Node node, PolicySet policySet) {
+ Element element = (Element)node;
+ Document document = element.getOwnerDocument();
+
+ QName qname = policySet.getName();
+ String prefix = DOMHelper.getPrefix(element, qname.getNamespaceURI());
+ if (prefix == null) {
+ // Find the a non-conflicting prefix
+ int i = 0;
+ while (true) {
+ prefix = "ns" + i;
+ String ns = DOMHelper.getNamespaceURI(element, prefix);
+ if (ns == null) {
+ break;
+ }
+ }
+ // Declare the namespace
+ Attr nsAttr = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, XMLNS_ATTRIBUTE + ":" + prefix);
+ nsAttr.setValue(qname.getNamespaceURI());
+ element.setAttributeNodeNS(nsAttr);
+ }
+ // Form the value as a qualified name
+ String qvalue = null;
+ if (DEFAULT_NS_PREFIX.equals(prefix)) {
+ qvalue = qname.getLocalPart();
+ } else {
+ qvalue = prefix + ":" + qname.getLocalPart();
+ }
+
+ // Check if the attribute exists
+ Attr attr = element.getAttributeNode("policySets");
+ if (attr == null) {
+ // Create the policySets attr
+ attr = document.createAttributeNS(null, "policySets");
+ attr.setValue(qvalue);
+ element.setAttributeNodeNS(attr);
+ return true;
+ } else {
+ // Append to the existing value
+ boolean duplicate = false;
+ String value = attr.getValue();
+ StringTokenizer tokenizer = new StringTokenizer(value);
+ while (tokenizer.hasMoreTokens()) {
+ String ps = tokenizer.nextToken();
+ int index = ps.indexOf(':');
+ String ns = null;
+ String localName = null;
+ if (index == -1) {
+ ns = DOMHelper.getNamespaceURI(element, DEFAULT_NS_PREFIX);
+ localName = ps;
+ } else {
+ ns = DOMHelper.getNamespaceURI(element, ps.substring(0, index));
+ localName = ps.substring(index + 1);
+ }
+ QName psName = new QName(ns, localName);
+ if (qname.equals(psName)) {
+ duplicate = true;
+ break;
+ }
+ }
+ if (!duplicate) {
+ // REVIEW: [rfeng] How to comply to POL40012?
+ value = value + " " + qvalue;
+ attr.setValue(value.trim());
+ return true;
+ }
+ return false;
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java
new file mode 100644
index 0000000000..67b143e95d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.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.builder.impl;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+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.CompositeReference;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.builder.Messages;
+import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.Problem;
+import org.apache.tuscany.sca.monitor.Problem.Severity;
+
+/**
+ * This class encapsulates utility methods to deal with reference definitions
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ReferenceConfigurationUtil {
+
+ /**
+ * Report a warning.
+ *
+ * @param problems
+ * @param message
+ * @param model
+ */
+ private static void warning(Monitor monitor, String message, Object model, String... messageParameters) {
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(ReferenceConfigurationUtil.class.getName(),
+ Messages.ASSEMBLY_VALIDATION,
+ Severity.WARNING,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
+ }
+
+ static 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;
+ }
+ }
+
+ static boolean validateMultiplicityAndTargets(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;
+ }
+
+ /**
+ * Follow a reference promotion chain down to the innermost (non composite)
+ * component references.
+ *
+ * @param compositeReference
+ * @return
+ */
+ static 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 static 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);
+ }
+ }
+ }
+
+ /**
+ * Override the bindings for a promoted reference from an outer component reference
+ *
+ * @param reference - the outer level reference
+ * @param promotedReference - the inner level promoted reference
+ */
+ static void reconcileReferenceBindings(Reference reference,
+ ComponentReference promotedReference,
+ AssemblyFactory assemblyFactory,
+ Monitor monitor) {
+
+ if (reference.getEndpointReferences().size() > 0) {
+ if (promotedReference.getMultiplicity() == Multiplicity.ONE_ONE || promotedReference.getMultiplicity() == Multiplicity.ZERO_ONE) {
+ // Override any existing wires for 0..1 and 1..1 multiplicity
+ promotedReference.getEndpointReferences().clear();
+ // For 0..1 and 1..1, there should not be more than 1 endpoint reference
+ if (reference.getEndpointReferences().size() > 1) {
+ warning(monitor, "ComponentReferenceMoreWire", promotedReference, promotedReference.getName());
+ } // end if
+ } // end if
+ // Clone the EndpointReferences from the outer level and add to the promoted reference
+ for (EndpointReference epRef : reference.getEndpointReferences()) {
+ EndpointReference epRefClone = copyHigherReference(epRef, promotedReference);
+ promotedReference.getEndpointReferences().add(epRefClone);
+ } // end for
+ } // end if
+
+ Set<Binding> callbackBindings = new HashSet<Binding>();
+ if (promotedReference.getCallback() != null) {
+ callbackBindings.addAll(promotedReference.getCallback().getBindings());
+ }
+ if (reference.getCallback() != null) {
+ callbackBindings.addAll(reference.getCallback().getBindings());
+ }
+ promotedReference.setCallback(assemblyFactory.createCallback());
+ for (Binding binding : callbackBindings) {
+ if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
+ promotedReference.getCallback().getBindings().add(binding);
+ } // end if
+ } // end for
+ } // end method reconcileReferenceBindings
+
+ /**
+ * 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 static EndpointReference copyHigherReference(EndpointReference epRef, ComponentReference promotedReference) {
+ EndpointReference epRefClone = null;
+ try {
+ epRefClone = (EndpointReference)epRef.clone();
+ } catch (Exception 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;
+ } // end copyHigherReference
+
+} // end class
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java
new file mode 100644
index 0000000000..ef03344131
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.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.builder.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * This class encapsulates utility methods to deal with service definitions.
+ *
+ * @version $Rev$ $Date$
+ */
+abstract class ServiceConfigurationUtil {
+
+ /**
+ * Follow a service promotion chain down to the inner most (non composite)
+ * component service.
+ *
+ * @param topCompositeService
+ * @return
+ */
+ static 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
+ */
+ static 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;
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java
new file mode 100644
index 0000000000..b543e3347d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.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.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) {
+ }
+
+ /**
+ * 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());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * 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 Composite build(Composite composite, BuilderContext context)
+ throws CompositeBuilderException {
+ configureStructuralURIs(composite, null, context.getDefinitions(), context.getBindingBaseURIs(), context.getMonitor());
+ return composite;
+ }
+
+ public String getID() {
+ return "org.apache.tuscany.sca.assembly.builder.StructualURIBuilder";
+ }
+
+ 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);
+
+ /*
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+ constructBindingURI(componentURI, service, binding, defaultBindings, 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java
new file mode 100644
index 0000000000..0c7105bd9f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.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.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.FactoryExtensionPoint;
+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);
+ FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java
new file mode 100644
index 0000000000..a99d0df91c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java
new file mode 100644
index 0000000000..dac50ec227
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java
new file mode 100644
index 0000000000..9102257b77
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java
new file mode 100644
index 0000000000..1201b6e36f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite
new file mode 100644
index 0000000000..d6082a936d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite
new file mode 100644
index 0000000000..105a478842
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite
new file mode 100644
index 0000000000..d3d5bafdfc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite
new file mode 100644
index 0000000000..12aa35b694
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Composite3">
+
+ <component name="Component3A">
+ <implementation.java class="sample.Component3AImpl"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite
new file mode 100644
index 0000000000..141ff2a4ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml
new file mode 100644
index 0000000000..fe76d0038a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg
new file mode 100644
index 0000000000..a010bb1bf1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png
new file mode 100644
index 0000000000..e1f78f6423
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml
new file mode 100644
index 0000000000..dac8e384e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" targetNamespace="http://test"
+ xmlns:test="http://test" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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/200903" 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/200903" 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/200903" 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/200903" 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/200903">
+ <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/200903" 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/200903" 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/200903" 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/tags/java/sca/2.0-M4-RC2/modules/common-java/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/common-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1795f1eacf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-java/META-INF/MANIFEST.MF
@@ -0,0 +1,24 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Common Java
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397108125
+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/tags/java/sca/2.0-M4-RC2/modules/common-java/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/common-java/pom.xml
new file mode 100644
index 0000000000..3ada1b0067
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>jdk15</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java
new file mode 100644
index 0000000000..b4b99ff9e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.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.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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java
new file mode 100644
index 0000000000..cc3fb4676d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.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.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) {
+ Collection<V> collection = get(key);
+ if (collection == null) {
+ return false;
+ }
+ return collection.remove(value);
+ }
+
+ protected Collection<V> createCollection() {
+ return new ArrayList<V>();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java
new file mode 100644
index 0000000000..d3f472d463
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.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.common.java.collection;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * A Simple LRU Cache
+ *
+ * @version $Revision$
+ * @param <K>
+ * @param <V>
+ */
+
+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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java
new file mode 100644
index 0000000000..469da29e38
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.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.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
+ */
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/common-xml/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1a40ccd3b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/META-INF/MANIFEST.MF
@@ -0,0 +1,58 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Common XML
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397108125
+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/tags/java/sca/2.0-M4-RC2/modules/common-xml/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/common-xml/pom.xml
new file mode 100644
index 0000000000..9d2c285f20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java
new file mode 100644
index 0000000000..33a97f4342
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java
new file mode 100644
index 0000000000..f2f63e80c6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java
new file mode 100644
index 0000000000..09d9d3062d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java
@@ -0,0 +1,498 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 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
+ */
+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 {
+ return createXMLStreamReader(openStream(url));
+ } 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);
+ }
+
+ /**
+ * 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);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java
new file mode 100644
index 0000000000..b35c6456e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java
new file mode 100644
index 0000000000..a65bd5fe15
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.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.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);
+
+ for (String prefix : getPrefixes(expression)) {
+ String namespace = context.getNamespaceURI(prefix);
+ if (namespace != null && !XMLConstants.NULL_NS_URI.equals(namespace)) {
+ nsContext.register(prefix, namespace);
+ }
+ }
+ return nsContext;
+ }
+
+ /**
+ * 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("([^:]+):([^:]+)");
+ 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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java
new file mode 100644
index 0000000000..a2922e9173
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.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.common.xml.xpath;
+
+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 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");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ xpathHelper = null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c70f81ea94
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+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
+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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/pom.xml
new file mode 100644
index 0000000000..8aeeebd9af
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java
new file mode 100644
index 0000000000..3f82f6fb17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java
new file mode 100644
index 0000000000..91f2bba5c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.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.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.Contribution;
+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 {
+
+ public OSGiBundleContributionScanner() {
+ }
+
+ public String getContributionType() {
+ return PackageType.BUNDLE;
+ }
+
+ public URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException {
+ Bundle bundle = null;
+ try {
+ bundle = OSGiBundleActivator.findBundle(contribution.getLocation());
+ if (bundle != null) {
+ URL url = bundle.getResource(artifact);
+ return url;
+ }
+ } catch (Exception e) {
+ }
+ return null;
+ }
+
+ public 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();
+ }
+ }
+
+ public List<String> 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<String> artifacts = new ArrayList<String>();
+ 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);
+ }
+ artifacts.add(entryName);
+
+ if (entryName.endsWith(".jar") && bundleClassPath.contains(entryName)) {
+ artifacts.addAll(getJarArtifacts(entry, entry.openStream()));
+ }
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ contribution.getExtensions().add(bundle);
+ contribution.getTypes().add(getContributionType());
+ contribution.setClassLoader(new BundleClassLoader(bundle));
+ return artifacts;
+ }
+
+ 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;
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/contribution/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/contribution/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a32ad146da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/META-INF/MANIFEST.MF
@@ -0,0 +1,61 @@
+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
+ "
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Contribution Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397102546
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/contribution/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/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/tags/java/sca/2.0-M4-RC2/modules/contribution/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/contribution/pom.xml
new file mode 100644
index 0000000000..556ffc6037
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java
new file mode 100644
index 0000000000..e3e1bd8fac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.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;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+
+/**
+ * Represents an artifact in an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java
new file mode 100644
index 0000000000..81b0b08b9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java
new file mode 100644
index 0000000000..bdc523c33e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java
new file mode 100644
index 0000000000..cba867cb80
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.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.contribution;
+
+
+/**
+ * A factory for the contribution model.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java
new file mode 100644
index 0000000000..5f26c3d907
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.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;
+
+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 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java
new file mode 100644
index 0000000000..98954c288a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java
new file mode 100644
index 0000000000..b2eddb8336
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java
new file mode 100644
index 0000000000..20798dcd17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.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 a default import that imports artifacts from
+ * all contributions.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface DefaultImport extends Import {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java
new file mode 100644
index 0000000000..a6e5afe7b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java
new file mode 100644
index 0000000000..256a2387f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.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;
+
+import org.apache.tuscany.sca.assembly.Extensible;
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+
+
+/**
+ * The representation of an import.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java
new file mode 100644
index 0000000000..c6c0aff737
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java
new file mode 100644
index 0000000000..a362e97fc6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java
new file mode 100644
index 0000000000..64bfb20bed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java
new file mode 100644
index 0000000000..7be9472fc9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.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.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 boolean unresolved;
+ 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 boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java
new file mode 100644
index 0000000000..da8c879a93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.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.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 boolean unresolved;
+ private List<Export> exports = new ArrayList<Export>();
+ private List<Import> imports = new ArrayList<Import>();
+ private List<Composite> deployables = new ArrayList<Composite>();
+
+ ContributionMetadataImpl() {
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public List<Export> getExports() {
+ return exports;
+ }
+
+ public List<Import> getImports() {
+ return imports;
+ }
+
+ public List<Composite> getDeployables() {
+ return deployables;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java
new file mode 100644
index 0000000000..d4614e5427
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java
new file mode 100644
index 0000000000..7ab535f916
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java
new file mode 100644
index 0000000000..886c61c00a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java
new file mode 100644
index 0000000000..41e93ec148
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java
new file mode 100644
index 0000000000..d3568f6283
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java
new file mode 100644
index 0000000000..ee94d889ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java
new file mode 100644
index 0000000000..86146fc31b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.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.contribution.java.impl;
+
+import java.io.IOException;
+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 Contribution contribution;
+ private ProcessorContext context;
+ private Map<String, ModelResolver> importResolvers = new HashMap<String, ModelResolver>();
+
+ 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 = contribution;
+ // Index Java import resolvers by package name
+ Map<String, List<ModelResolver>> resolverMap = new HashMap<String, List<ModelResolver>>();
+ for (Import import_: this.contribution.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;
+ // Load the class and return a class reference for it
+ String className = ((ClassReference)unresolved).getClassName();
+ Class<?> clazz = Class.forName(className, true, this);
+ return modelClass.cast(new ClassReference(clazz));
+
+ } catch (ClassNotFoundException e) {
+ return unresolved;
+ } catch (NoClassDefFoundError 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()) {
+ return classReference.getJavaClass();
+ }
+ }
+
+ // Next, try to load the class from the current contribution
+ Class<?> clazz = super.findClass(name);
+ return clazz;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java
new file mode 100644
index 0000000000..25b3eae350
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
new file mode 100644
index 0000000000..be175d000e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java
new file mode 100644
index 0000000000..c0bd9465e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java
new file mode 100644
index 0000000000..9b02ce4abb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java
new file mode 100644
index 0000000000..de25081832
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java
new file mode 100644
index 0000000000..3bf9e54774
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java
new file mode 100644
index 0000000000..f2fdb3278e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java
new file mode 100644
index 0000000000..344e730bdc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java
new file mode 100644
index 0000000000..c16660277a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.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.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.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 implements StAXArtifactProcessor<JavaImport> {
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+
+ 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 = reader.getAttributeValue(null, 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java
new file mode 100644
index 0000000000..a71fa61a54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java
new file mode 100644
index 0000000000..c68aee8521
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java
new file mode 100644
index 0000000000..8af36d7da0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.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.namespace;
+
+import org.apache.tuscany.sca.contribution.Import;
+
+/**
+ * The representation of an XML namespace import.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java
new file mode 100644
index 0000000000..cfbac8bb1f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java
new file mode 100644
index 0000000000..99af328964
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java
new file mode 100644
index 0000000000..7bf3c32c93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java
new file mode 100644
index 0000000000..a23f38e8ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.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.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/200903";
+ 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 {
+ readExtendedElement(reader, namespaceExport, extensionProcessor, context);
+ }
+
+ 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);
+
+ writeExtendedElements(writer, namespaceExport, extensionProcessor, 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java
new file mode 100644
index 0000000000..1146e593a9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java
new file mode 100644
index 0000000000..35e2d539d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java
new file mode 100644
index 0000000000..2efa8d6aca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.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.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/200903";
+
+ 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 = reader.getAttributeValue(null, LOCATION);
+ if (location != null) {
+ namespaceImport.setLocation(location);
+ }
+ readExtendedAttributes(reader, namespaceImport, attributeProcessor, extensionFactory, context);
+ } else {
+ readExtendedElement(reader, namespaceImport, extensionProcessor, context);
+ }
+ 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);
+ writeExtendedElements(writer, namespaceImport, extensionProcessor, context);
+ writer.writeEndElement();
+ }
+
+
+ public void resolve(NamespaceImport model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
new file mode 100644
index 0000000000..9ac3aebaf6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java
new file mode 100644
index 0000000000..817e5a5ee2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.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.contribution.processor;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+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$
+ */
+public abstract class BaseStAXArtifactProcessor {
+ /**
+ * 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);
+ }
+
+ /**
+ * 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 {
+ for (Object ext : extensible.getExtensions()) {
+ extensionProcessor.write(ext, writer, context);
+ }
+ }
+
+ /**
+ * 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/200903";
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java
new file mode 100644
index 0000000000..3b99eba586
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.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 exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java
new file mode 100644
index 0000000000..6fd7d0c91e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.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.contribution.processor;
+
+
+/**
+ * Denotes an exception while reading artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java
new file mode 100644
index 0000000000..fe1a09d398
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.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.processor;
+
+
+/**
+ * Denotes a problem while resolving models inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java
new file mode 100644
index 0000000000..0039dd9f8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.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.contribution.processor;
+
+/**
+ * Base class for runtime exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java
new file mode 100644
index 0000000000..286c9dc791
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.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;
+
+
+
+/**
+ * Denotes an exception while writing artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..c871e4c868
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..151edeae0b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
new file mode 100644
index 0000000000..e76d6cb299
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..e22d7762fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java
new file mode 100644
index 0000000000..59fa5990d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java
new file mode 100644
index 0000000000..da7a57a687
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.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 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 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) {
+ super();
+ this.registry = registry;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java
new file mode 100644
index 0000000000..ca579110ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java
new file mode 100644
index 0000000000..2639a21e41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
new file mode 100644
index 0000000000..132b7a8858
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
new file mode 100644
index 0000000000..aa159ac629
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java
new file mode 100644
index 0000000000..77940df5aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java
new file mode 100644
index 0000000000..16404ec78a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.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.processor;
+
+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
+ */
+public class ProcessorContext {
+ protected Contribution contribution;
+ 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();
+ }
+
+ public Contribution getContribution() {
+ return contribution;
+ }
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java
new file mode 100644
index 0000000000..8927acd776
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..0cfcf004b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.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 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
new file mode 100644
index 0000000000..d33b2c1028
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.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 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java
new file mode 100644
index 0000000000..dbc0a2c7bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java
new file mode 100644
index 0000000000..dd098283bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.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.contribution.processor;
+
+import java.net.URI;
+import java.net.URL;
+
+
+/**
+ * An artifact processor that can read models from a URL.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java
new file mode 100644
index 0000000000..4806d443eb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.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.contribution.processor;
+
+import java.util.Collection;
+
+/**
+ * An extension point for URL artifact processors.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java
new file mode 100644
index 0000000000..4c6f0b7282
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java
new file mode 100644
index 0000000000..8a166e42f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java
new file mode 100644
index 0000000000..ce94cef6a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java
new file mode 100644
index 0000000000..756cd9eb78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.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.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
+ */
+ public static void setMonitor(XMLStreamReader reader, Monitor monitor) {
+ if (reader instanceof ValidatingXMLStreamReader) {
+ ((ValidatingXMLStreamReader)reader).setMonitor(monitor);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java
new file mode 100644
index 0000000000..bd5731c594
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java
@@ -0,0 +1,406 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 = input;
+ if( ValidatingXMLStreamReader.this.monitor != null ) {
+ artifactName = ValidatingXMLStreamReader.this.monitor.getArtifactName();
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java
new file mode 100644
index 0000000000..67ec55b72e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
new file mode 100644
index 0000000000..09a6b7dd80
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.List;
+
+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.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();
+ } else {
+ scanner = new JarContributionScanner();
+ }
+ }
+
+ // Scan the contribution and list the artifacts contained in it
+ List<Artifact> artifacts = contribution.getArtifacts();
+ boolean contributionMetadata = false;
+ List<String> artifactURIs = scanner.scan(contribution);
+ for (String artifactURI: artifactURIs) {
+ URL artifactURL = scanner.getArtifactURL(contribution, artifactURI);
+
+ // Add the deployed artifact model to the contribution
+ Artifact artifact = this.contributionFactory.createArtifact();
+ artifact.setURI(artifactURI);
+ artifact.setLocation(artifactURL.toString());
+ artifacts.add(artifact);
+ modelResolver.addModel(artifact, context);
+
+ monitor.pushContext("Artifact: " + artifactURI);
+
+ old = context.setContribution(contribution);
+ try {
+ // Read each artifact
+ Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL, 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.setContribution(old);
+ }
+ }
+
+ // 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);
+ }
+ } 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();
+
+ // Resolve all artifact models
+ for (Artifact artifact : contribution.getArtifacts()) {
+ Object model = artifact.getModel();
+ if (model != null) {
+ try {
+ artifactProcessor.resolve(model, contributionResolver, context);
+ } catch (Throwable e) {
+ throw new ContributionResolveException(e);
+ }
+ }
+ }
+
+ // 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)contributionResolver.resolveModel(Composite.class, deployable, context);
+ if (resolved != deployable) {
+ deployables.set(i, resolved);
+ }
+ } // end for
+ } 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java
new file mode 100644
index 0000000000..f589c6b911
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java
new file mode 100644
index 0000000000..db4feeec48
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java
new file mode 100644
index 0000000000..f3555ee71e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.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.contribution.resolver;
+
+import java.lang.ref.WeakReference;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * 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$
+ */
+public class ClassReference implements Base {
+
+ private WeakReference<Class<?>> clazz;
+ private String className;
+
+ /**
+ * 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;
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java
new file mode 100644
index 0000000000..e17dd176a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java
new file mode 100644
index 0000000000..7745253bba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java
new file mode 100644
index 0000000000..8a11cb42f8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
new file mode 100644
index 0000000000..94b2fb0058
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
new file mode 100644
index 0000000000..ac16d413eb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.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.contribution.resolver;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+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.getName());
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load model resolvers
+ for (ServiceDeclaration modelResolverDeclaration : modelResolverDeclarations) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
new file mode 100644
index 0000000000..72e4b03c7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java
new file mode 100644
index 0000000000..ec8495d1d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java
new file mode 100644
index 0000000000..4a25059792
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java
new file mode 100644
index 0000000000..74f0f2d71d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.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.resolver;
+
+/**
+ * Extension to assembly model implementations to provide a model resolver.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java
new file mode 100644
index 0000000000..dfe8f08719
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
new file mode 100644
index 0000000000..d2f29a001b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.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.contribution.scanner;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+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$
+ */
+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 URIs
+ * @throws ContributionReadException
+ * @throws IOException
+ */
+ List<String> scan(Contribution contribution) throws ContributionReadException;
+
+ /**
+ * Return the URL for an artifact in the contribution.
+ *
+ * This is needed for archives such as jar files that have specific URL schemes
+ * for the artifacts they contain.
+ *
+ * @param contribution Contribution URL
+ * @param artifact The relative URI for the artifact
+ * @throws ContributionReadException
+ * @return The artifact URL
+ */
+ URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java
new file mode 100644
index 0000000000..1ca9def4ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
new file mode 100644
index 0000000000..610a1eb7ba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.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.contribution.scanner;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.Collection;
+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.processor.ContributionReadException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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(contributionType, scannerDeclaration);
+ addContributionScanner(scanner);
+ }
+
+ loaded = true;
+ }
+
+ /**
+ * A facade for contribution scanners.
+ */
+ private static class LazyContributionScanner implements ContributionScanner {
+
+ private ServiceDeclaration scannerDeclaration;
+ private String contributionType;
+ private ContributionScanner scanner;
+
+ private LazyContributionScanner(String contributionType, ServiceDeclaration scannerDeclaration) {
+ this.scannerDeclaration = scannerDeclaration;
+ this.contributionType = contributionType;
+ }
+
+ public URL getArtifactURL(Contribution contributionSourceURL, String artifact) throws ContributionReadException {
+ return getScanner().getArtifactURL(contributionSourceURL, artifact);
+ }
+
+ public List<String> 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();
+ scanner = constructor.newInstance();
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return scanner;
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java
new file mode 100644
index 0000000000..144302c3e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.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.scanner.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+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 {
+
+ public DirectoryContributionScanner() {
+ }
+
+ public String getContributionType() {
+ return PackageType.FOLDER;
+ }
+
+ public URL getArtifactURL(Contribution contribution, String artifact) throws ContributionReadException {
+ File directory = directory(contribution);
+ File file = new File(directory, artifact);
+ try {
+ return file.toURI().toURL();
+ } catch (MalformedURLException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public List<String> scan(Contribution contribution) throws ContributionReadException {
+ File directory = directory(contribution);
+ List<String> artifacts = new ArrayList<String>();
+ try {
+ traverse(artifacts, directory, directory);
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ }
+ contribution.getTypes().add(getContributionType());
+ 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) throws IOException {
+ if (file.isFile()) {
+ 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);
+ }
+ }
+ }
+ }
+
+ private static 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java
new file mode 100644
index 0000000000..2c5b849a20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.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.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.Contribution;
+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 {
+
+ public JarContributionScanner() {
+ }
+
+ public String getContributionType() {
+ return PackageType.JAR;
+ }
+
+ public 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);
+ }
+ }
+
+ public List<String> 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 URIs
+ List<String> artifacts = new ArrayList<String>(names);
+ contribution.getTypes().add(getContributionType());
+ return artifacts;
+
+ } finally {
+ jar.close();
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ public void postProcess(Contribution contribution) {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java
new file mode 100644
index 0000000000..0ad3ecbd4d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java
new file mode 100644
index 0000000000..30220901a0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
new file mode 100644
index 0000000000..4700041775
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
@@ -0,0 +1,245 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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/200903";
+
+ 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.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) {
+ contribution.getImports().add((Import)extension);
+ } else if (extension instanceof Export) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java
new file mode 100644
index 0000000000..916630939e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory
new file mode 100644
index 0000000000..8fc5aac46f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..6aba85a94d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#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/200903#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/200903#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/200903#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/200903#export.java,model=org.apache.tuscany.sca.contribution.java.JavaExport
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-java-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-java-validation-messages.properties
new file mode 100644
index 0000000000..09fc3e9fff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties
new file mode 100644
index 0000000000..c1cbd06e7f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-validation-messages.properties
new file mode 100644
index 0000000000..63c4746a4d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
new file mode 100644
index 0000000000..4827fd5e94
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/main/resources/contribution-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.
+#
+#
+XMLStreamException = XMLStreamException occured due to : {0}
+IOException = IOException occured due to : {0}
+AttributeCompositeMissing = Attribute 'composite' is missing
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java
new file mode 100644
index 0000000000..8409dd9491
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java
new file mode 100644
index 0000000000..f25fb5d981
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\"/>";
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java
new file mode 100644
index 0000000000..f3b52117bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java
new file mode 100644
index 0000000000..cec66b23c3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java
new file mode 100644
index 0000000000..03407f9065
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java
new file mode 100644
index 0000000000..9587d3c024
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java
new file mode 100644
index 0000000000..58d1616aa2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
new file mode 100644
index 0000000000..7692c8ecdf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java
new file mode 100644
index 0000000000..c04d56cafe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java
new file mode 100644
index 0000000000..1d0ea5dc8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.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.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 VALID_XML =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<contribution xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\""
+ + " 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/200903\" 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());
+ }
+
+ @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());
+ }
+
+ @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);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/deployables/sample-calculator.jar b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/deployables/sample-calculator.jar
new file mode 100644
index 0000000000..0ca3a1b781
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/deployables/sample-calculator.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/repository/sample-calculator.jar b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/repository/sample-calculator.jar
new file mode 100644
index 0000000000..9c46c679d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/repository/sample-calculator.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.composite b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.composite
new file mode 100644
index 0000000000..1e09549194
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.ext b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.ext
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/contribution/src/test/resources/test.ext
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-databinding/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..7f15944428
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/META-INF/MANIFEST.MF
@@ -0,0 +1,46 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Core/DataBinding Integration
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397235359
+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.bind.annotation.adapters,
+ javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ org.apache.tuscany.sca.assembly;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.context;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.xml;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.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.invocation;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",
+ org.oasisopen.sca;version="2.0.0",
+ org.oasisopen.sca.annotation;version="2.0.0",
+ org.w3c.dom;resolution:=optional
+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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/pom.xml
new file mode 100644
index 0000000000..5faf7fb1a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/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>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-modules</artifactId>
+ <version>2.0-M4</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-databinding-jaxb</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>compile</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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java
new file mode 100644
index 0000000000..7146f0fa36
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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.impl.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java
new file mode 100644
index 0000000000..71e2a24def
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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.impl.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Throwable> getSourceType() {
+ return Throwable.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java
new file mode 100644
index 0000000000..3422713bb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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.impl.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object[]> getSourceType() {
+ return Object[].class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java
new file mode 100644
index 0000000000..08442134b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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.impl.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java
new file mode 100644
index 0000000000..446651c918
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.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.core.databinding.wire;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+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.RuntimeWire;
+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(RuntimeWire wire) {
+ InterfaceContract sourceContract = wire.getEndpointReference().getInterfaceContract();
+ InterfaceContract targetContract = wire.getEndpoint().getInterfaceContract();
+ if (targetContract == null) {
+ targetContract = sourceContract;
+ }
+
+ if (!sourceContract.getInterface().isRemotable()) {
+ return;
+ }
+ List<InvocationChain> chains = wire.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(wire, sourceOperation, targetOperation, mediator);
+ } else {
+ // assume pass-by-values copies are required if interfaces are remotable and there is no data binding
+ // transformation, i.e. a transformation will result in a copy so another pass-by-value copy is unnecessary
+ if (!isOnMessage(targetOperation) && isRemotable(chain, sourceOperation, targetOperation)) {
+ interceptor =
+ new PassByValueInterceptor(mediator, chain, targetOperation);
+ }
+ }
+ if (interceptor != null) {
+ String phase =
+ (wire.getEndpointReference().getReference() instanceof ComponentReference) ? Phase.REFERENCE_INTERFACE
+ : Phase.SERVICE_INTERFACE;
+ chain.addInterceptor(phase, interceptor);
+ }
+ }
+
+ }
+
+ /**
+ * FIXME: TUSCANY-2586, temporary work around till the JIRA is fixed to prevent
+ * the PassByValueInterceptor being used for services when the binding protocol
+ * doesn't need the copies done.
+ */
+ protected boolean isOnMessage(Operation op) {
+ return "onMessage".equals(op.getName());
+ }
+
+ /**
+ * Pass-by-value copies are required if the interfaces are remotable unless the
+ * implementation uses the @AllowsPassByReference annotation.
+ */
+ protected boolean isRemotable(InvocationChain chain, Operation sourceOperation, Operation targetOperation) {
+ if (!sourceOperation.getInterface().isRemotable()) {
+ return false;
+ }
+ if (!targetOperation.getInterface().isRemotable()) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java
new file mode 100644
index 0000000000..679897b59b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.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.core.databinding.wire;
+
+import java.lang.reflect.InvocationTargetException;
+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.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.FaultException;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+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.RuntimeWire;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * An interceptor to transform data across databindings on the wire
+ *
+ * @version $Rev$ $Date$
+ */
+public class DataTransformationInterceptor implements Interceptor, DataExchangeSemantics {
+ private Invoker next;
+
+ private Operation sourceOperation;
+
+ private Operation targetOperation;
+ private RuntimeWire wire;
+ private Mediator mediator;
+
+ public DataTransformationInterceptor(RuntimeWire wire,
+ Operation sourceOperation,
+ Operation targetOperation,
+ Mediator mediator) {
+ super();
+ this.sourceOperation = sourceOperation;
+ this.targetOperation = targetOperation;
+ this.mediator = mediator;
+ this.wire = wire;
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public Message invoke(Message msg) {
+ Map<String, Object> metadata = new HashMap<String, Object>();
+ metadata.put("wire", wire);
+ 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;
+ }
+
+ public boolean allowsPassByReference() {
+ return true;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java
new file mode 100644
index 0000000000..a4466bfd1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.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.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;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/core-spi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/core-spi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..170bc6314d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/META-INF/MANIFEST.MF
@@ -0,0 +1,50 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Core SPI
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397108125
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/core-spi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/core-spi/pom.xml
new file mode 100644
index 0000000000..3d7cd93a87
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</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>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/doc/Context Model.emx b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/doc/Context Model.emx
new file mode 100644
index 0000000000..0445ea5a6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java
new file mode 100644
index 0000000000..d956689af3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.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.context;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.ComponentContext;
+
+/**
+ * Interface implemented by the provider of the ComponentContext.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java
new file mode 100644
index 0000000000..a805985a11
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.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.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.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 abstract class CompositeContext {
+ /**
+ * @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 context = component.getComponentContext();
+ return context.getCompositeContext();
+ }
+ return null;
+ }
+
+ /**
+ * Attach a component context to the component
+ * @param runtimeComponent
+ */
+ public abstract void bindComponent(RuntimeComponent runtimeComponent);
+
+ /**
+ *
+ * @param endpointReference
+ */
+ public abstract void bindEndpointReference(EndpointReference endpointReference);
+
+ /**
+ * Get the ExtensionPointRegistry for this node
+ * @return The ExtensionPointRegistry
+ */
+ public abstract ExtensionPointRegistry getExtensionPointRegistry();
+
+ /**
+ * Get the EndpointRegistry
+ * @return The EndpointRegistry for this node
+ */
+ public abstract EndpointRegistry getEndpointRegistry();
+
+ public abstract Composite getDomainComposite();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java
new file mode 100644
index 0000000000..e92a8f2844
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.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.context;
+
+/**
+ * An extension point for context factories.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java
new file mode 100644
index 0000000000..c079a9dc66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.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.context;
+
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java
new file mode 100644
index 0000000000..9766e164b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.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.context;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+
+/**
+ * Interface implemented by the provider of the property values
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java
new file mode 100644
index 0000000000..d8f15b411c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.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.context;
+
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.oasisopen.sca.RequestContext;
+
+/**
+ * Interface implemented by the provider of the RequestContext.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RequestContextFactory {
+ /**
+ * @return An instance of RequestContext for the current invocation
+ */
+ RequestContext createRequestContext(RuntimeComponent component);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java
new file mode 100644
index 0000000000..d6237b7ce3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java
new file mode 100644
index 0000000000..957a15ce8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java
new file mode 100644
index 0000000000..a5f221fc11
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.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.invocation;
+
+/**
+ * Synchronous mediation associated with a client- or target- side wire.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
new file mode 100644
index 0000000000..4f131365fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.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.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$
+ */
+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();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java
new file mode 100644
index 0000000000..2748bbed9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.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.invocation;
+
+/**
+ * Synchronous mediation associated with a client- or target- side wire.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java
new file mode 100644
index 0000000000..9bf8355ef1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.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.invocation;
+
+import java.util.List;
+
+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$
+ */
+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
+ */
+ List<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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java
new file mode 100644
index 0000000000..38c900e36a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.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.invocation;
+
+
+/**
+ * A factory for messages
+ *
+ * @version $Rev $Date$
+ */
+public interface MessageFactory {
+
+ /**
+ * Creates a new message.
+ *
+ * @return The new message
+ */
+ Message createMessage();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java
new file mode 100644
index 0000000000..af8ad6e582
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.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.invocation;
+
+/**
+ * Tuscany built-in phases for the invocation chain
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Phase {
+ // The first phase for outgoing invocations via a reference
+ String REFERENCE = "component.reference";
+
+ // data transformation and validation
+ String REFERENCE_INTERFACE = "reference.interface";
+
+ // reference policy handling
+ String REFERENCE_POLICY = "reference.policy";
+
+ // reference binding invoker
+ String REFERENCE_BINDING = "reference.binding";
+
+ String REFERENCE_BINDING_WIREFORMAT = "reference.binding.wireformat";
+ String REFERENCE_BINDING_POLICY = "reference.binding.policy";
+ String REFERENCE_BINDING_TRANSPORT = "reference.binding.transport";
+
+ 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";
+
+
+ // The first phase for incoming invocations via a service
+ String SERVICE_BINDING = "service.binding";
+
+ // service policy handling
+ String SERVICE_POLICY = "service.policy";
+
+ // data validation and transformation
+ String SERVICE_INTERFACE = "service.interface";
+
+ // TODO: not sure if we need to have this face
+ String SERVICE = "component.service";
+
+ // implementation policy handling
+ String IMPLEMENTATION_POLICY = "implementation.policy";
+
+ // implementation invoker
+ String IMPLEMENTATION = "component.implementation";
+
+ // String getName();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java
new file mode 100644
index 0000000000..4482eaa0bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.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.invocation;
+
+/**
+ * An interceptor that is designated to be a given phase
+ */
+public interface PhasedInterceptor extends Interceptor {
+ /**
+ * Get the name of the phase that this interceptor is positioned
+ * @return
+ */
+ String getPhase();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java
new file mode 100644
index 0000000000..222ba62fb6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java
new file mode 100644
index 0000000000..3887db4873
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java
new file mode 100644
index 0000000000..785ac70271
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.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.provider;
+
+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.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * Abstract base class for policy providers
+ */
+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()));
+ }
+ }
+
+ }
+ }
+ 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;
+ }
+
+ private InvocationChain getInvocationChain() {
+ if (subject instanceof Endpoint) {
+ Endpoint endpoint = (Endpoint)subject;
+ RuntimeComponentService service = (RuntimeComponentService)endpoint.getService();
+ RuntimeWire wire = service.getRuntimeWire(endpoint.getBinding());
+ List<InvocationChain> chains = wire.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+
+ } else if (subject instanceof EndpointReference) {
+ EndpointReference endpointReference = (EndpointReference)subject;
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ RuntimeWire wire = reference.getRuntimeWire(endpointReference.getBinding());
+ List<InvocationChain> chains = wire.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getSourceOperation());
+ }
+ } else if (subject instanceof Component) {
+ Component component = (Component)subject;
+ for (ComponentService s : component.getServices()) {
+ RuntimeComponentService service = (RuntimeComponentService)s;
+ for (RuntimeWire wire : service.getRuntimeWires()) {
+ List<InvocationChain> chains = wire.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+ }
+
+ }
+ }
+ return null;
+ }
+
+ protected void configure(InvocationChain invocationChain, Operation operation) {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
new file mode 100644
index 0000000000..0e94a28d98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.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.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+
+/**
+ * A factory for creating the runtime artifacts that represent bindings.
+ *
+ * @version $Rev$ $Date$
+ */
+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(EndpointReference 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(Endpoint endpoint);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..2ee058a14d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -0,0 +1,498 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.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.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * 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);
+ }
+ 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;
+ }
+
+ /**
+ * 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);
+ }
+
+ // Get the target extension point
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
+ registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ 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);
+ factoryExtensionPoint.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);
+ factoryExtensionPoint.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);
+ factoryExtensionPoint.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);
+ factoryExtensionPoint.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);
+ factoryExtensionPoint.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(EndpointReference endpointReference) {
+ return getFactory().createReferenceBindingProvider(endpointReference);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ServiceBindingProvider createServiceBindingProvider(Endpoint 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(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding){
+ return getFactory().createReferenceWireFormatProvider(component, reference, binding);
+ }
+
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding){
+ return getFactory().createServiceWireFormatProvider(component, service, binding);
+ }
+
+ 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(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding){
+ return getFactory().createReferenceOperationSelectorProvider(component, reference, binding);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding){
+ return getFactory().createServiceOperationSelectorProvider(component, service, binding);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
new file mode 100644
index 0000000000..015c673d66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.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.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$
+ */
+public interface ImplementationProvider {
+
+ /**
+ * This method will be invoked when the component implementation
+ * is activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component implementation
+ * is deactivated.
+ */
+ void stop();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
new file mode 100644
index 0000000000..6a37d1e951
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java
new file mode 100644
index 0000000000..f385c7dfba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.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.provider;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..183b38cb33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.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.assembly.Binding;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface OperationSelectorProviderFactory<M extends OperationSelector> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param component
+ * @param reference
+ * @param binding
+ * @return
+ */
+ OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param component
+ * @param service
+ * @param binding
+ * @return
+ */
+ OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java
new file mode 100644
index 0000000000..f2b59a7c54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
new file mode 100644
index 0000000000..00ef0d1c3c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface PolicyProvider {
+ /**
+ * Create an interceptor for a given operation
+ * @param operation
+ * @return An interceptor that realize the policySet
+ */
+ PhasedInterceptor createInterceptor(Operation operation);
+
+ /**
+ * Start the provider
+ */
+ void start();
+
+ /**
+ * Stop the provider
+ */
+ void stop();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
new file mode 100644
index 0000000000..564e6c633b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java
new file mode 100644
index 0000000000..6e7f2bd554
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.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 PolicyProviderRRB extends PolicyProvider {
+ /**
+ * Create a binding interceptor
+ * @return An interceptor that realize the policySet
+ */
+ PhasedInterceptor createBindingInterceptor();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java
new file mode 100644
index 0000000000..2102806881
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..d8f9973338
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.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.provider;
+
+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$
+ */
+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();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
new file mode 100644
index 0000000000..b3ab1d8b87
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.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.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$
+ */
+public interface ReferenceBindingProvider {
+
+ /**
+ * This method will be invoked when the component reference binding is
+ * activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component reference binding is
+ * deactivated.
+ */
+ void stop();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java
new file mode 100644
index 0000000000..3ea9d0ac3c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.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;
+
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * TODO RRB experiment
+ * This is an experiment extension to try out the request response
+ * binding function
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ReferenceBindingProviderRRB extends ReferenceBindingProvider {
+
+ void configureBindingChain(RuntimeWire runtimeWire);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
new file mode 100644
index 0000000000..e15234a549
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.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.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$
+ */
+public interface ServiceBindingProvider {
+ /**
+ * This method will be invoked when the component service binding is
+ * activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component service binding is
+ * deactivated.
+ */
+ void stop();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java
new file mode 100644
index 0000000000..278bb23e0a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.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;
+
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+/**
+ * TODO RRB experiment
+ * This is an experiment extension to try out the request response
+ * binding function
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServiceBindingProviderRRB extends ServiceBindingProvider {
+
+ void configureBindingChain(RuntimeWire runtimeWire);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java
new file mode 100644
index 0000000000..b3a2b4763e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.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.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java
new file mode 100644
index 0000000000..fd748df6ca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.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.assembly.Binding;
+import org.apache.tuscany.sca.assembly.WireFormat;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface WireFormatProviderFactory<M extends WireFormat> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param component
+ * @param reference
+ * @param binding
+ * @return
+ */
+ WireFormatProvider createReferenceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param component
+ * @param service
+ * @param binding
+ * @return
+ */
+ WireFormatProvider createServiceWireFormatProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java
new file mode 100644
index 0000000000..b015891e93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java
new file mode 100644
index 0000000000..f4e18f60cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.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 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 start(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, 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
+ * @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;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java
new file mode 100644
index 0000000000..283d1d1a8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java
new file mode 100644
index 0000000000..7b71406ac6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.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.Collection;
+import java.util.List;
+
+/**
+ *
+ */
+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();
+ void addListener(EndpointListener listener);
+ void removeListener(EndpointListener listener);
+ List<EndpointListener> getListeners();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java
new file mode 100644
index 0000000000..13d193c464
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java
new file mode 100644
index 0000000000..78a0e19f10
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.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.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
+ */
+ boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+ /**
+ *
+ * @param endpointRegistry
+ * @param endpointReference
+ * @return
+ */
+ boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java
new file mode 100644
index 0000000000..09f4a4d78d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.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.runtime;
+
+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
+ */
+public interface EndpointRegistry {
+ void addEndpoint(Endpoint endpoint);
+ void removeEndpoint(Endpoint endpoint);
+
+ Endpoint getEndpoint(String uri);
+ void updateEndpoint(String uri, Endpoint endpoint);
+ List<Endpoint> findEndpoint(EndpointReference endpointReference);
+ List<Endpoint> getEndpoints();
+
+ void addEndpointReference(EndpointReference endpointReference);
+ void removeEndpointReference(EndpointReference endpointReference);
+ List<EndpointReference> findEndpointReference(Endpoint endpoint);
+ List<EndpointReference> getEndpointRefereneces();
+
+ void addListener(EndpointListener listener);
+ void removeListener(EndpointListener listener);
+ List<EndpointListener> getListeners();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java
new file mode 100644
index 0000000000..c56869170a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.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 java.io.IOException;
+
+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 {
+ void read(Endpoint endpoint, String xml) throws IOException;
+
+ String write(Endpoint endpoint) throws IOException;
+
+ void read(EndpointReference endpointReference, String xml) throws IOException;
+
+ String write(EndpointReference endpointReference) throws IOException;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java
new file mode 100644
index 0000000000..928c77fd04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java
new file mode 100644
index 0000000000..30bba78a40
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java
new file mode 100644
index 0000000000..5f9ff4fa7e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.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.runtime;
+
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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 reference The reference to be wired
+ * @param endpointReference The endpointReference to be used
+ * @return A service reference representing the wire
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ RuntimeComponentReference reference,
+ EndpointReference endpointReference);
+
+ /**
+ * Bind the reference to a target component/componentService
+ * @param <B>
+ * @param businessInterface The business interface
+ * @param reference The reference to be wired
+ * @param component The target component
+ * @param service The target component service
+ * @return A service reference representing the wire
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ RuntimeComponentReference reference,
+ RuntimeComponent component,
+ RuntimeComponentService service);
+
+ /**
+ * Create a CallableReference for the given component service
+ * @param <B>
+ * @param businessInterface
+ * @param component
+ * @param service
+ * @return
+ */
+ <B> ServiceReference<B> getCallableReference(Class<B> businessInterface,
+ RuntimeComponent component,
+ RuntimeComponentService service);
+
+ /**
+ * @param <B>
+ * @param businessInterface
+ * @param service
+ * @return
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, ComponentService service);
+
+ ExtensionPointRegistry getExtensionPointRegistry();
+ CompositeContext getCompositeContext();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java
new file mode 100644
index 0000000000..0105abd6e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.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.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+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.invocation.Invoker;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+/**
+ * The runtime component reference. Provides the bridge between the
+ * assembly model representation of a component reference and its runtime
+ * realization
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeComponentReference extends ComponentReference {
+
+ /**
+ * Get a list of runtime wires to the reference
+ *
+ * @return The list of wires
+ */
+ List<RuntimeWire> getRuntimeWires();
+
+ /**
+ * Get the runtime wire for the given binding
+ * @param binding The assembly model binding
+ * @return The runtime wire
+ */
+ RuntimeWire getRuntimeWire(Binding binding);
+
+ /**
+ * Get the runtime wire for the given endpoint reference
+ * @param endpointReference The assembly model endpoint reference
+ * @return The runtime wire
+ */
+ RuntimeWire getRuntimeWire(EndpointReference endpointReference);
+
+ /**
+ * Returns the reference binding provider associated with this
+ * component reference and the given binding.
+ *
+ * @param binding The assembly model binding
+ * @return The runtime reference binding provider
+ */
+ ReferenceBindingProvider getBindingProvider(Binding binding);
+
+ /**
+ * Sets the reference binding provider associated with this
+ * component reference and the given binding.
+ *
+ * @param binding The assembly model binding
+ * @param bindingProvider The runtime reference binding provider
+ */
+ void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider);
+
+
+ /**
+ * Add a policy provider for the given binding to the reference
+ * @param binding The assembly model binding
+ * @param policyProvider The policy handler
+ */
+ void addPolicyProvider(Binding binding, PolicyProvider policyProvider);
+
+ /**
+ * Get a list of policy providers for the given binding
+ * @param binding The assembly model binding
+ * @return A list of policy providers for the given binding
+ */
+ List<PolicyProvider> getPolicyProviders(Binding binding);
+
+ /**
+ * Get the invoker for the given binding and operation
+ * @param binding The assembly model binding
+ * @param operation The assembly model operation
+ * @return The runtime Invoker
+ */
+ Invoker getInvoker(Binding binding, Operation operation);
+
+ /**
+ * Set the owning component
+ * @param component
+ */
+ void setComponent(RuntimeComponent component);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java
new file mode 100644
index 0000000000..982724d798
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.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.runtime;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.ComponentService;
+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.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+
+/**
+ * The runtime component service. Provides the bridge between the
+ * assembly model representation of a component service and its runtime
+ * realization
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeComponentService extends ComponentService {
+
+ /**
+ * Get a list of runtime wires to the service
+ *
+ * @return The list of wires
+ */
+ List<RuntimeWire> getRuntimeWires();
+ /**
+ * Get the runtime wire for the given binding
+ * @param binding The assembly model binding
+ * @return The runtime wire
+ */
+ RuntimeWire getRuntimeWire(Binding binding);
+
+ /**
+ * Get the callback wires associated with this service
+ *
+ * @return The list of runtime callback wires
+ */
+ List<RuntimeWire> getCallbackWires();
+
+ /**
+ * Returns the service binding provider associated with this
+ * component service and the given binding.
+ *
+ * @param binding The assembly model binding
+ * @return The runtime service binding provider
+ */
+ ServiceBindingProvider getBindingProvider(Binding binding);
+
+ /**
+ * Returns the service binding provider associated with this
+ * component service and the given binding.
+ *
+ * @param binding
+ * @param interfaceContract
+ * @return
+ */
+ RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract);
+
+ /**
+ * Sets the service binding provider associated with this
+ * component service and the given binding.
+ *
+ * @param binding The assembly model binding
+ * @param bindingProvider The runtime service binding provider
+ */
+ void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider);
+
+ /**
+ * Get the invoker for the given binding and operation
+ * @param binding The assembly model binding
+ * @param operation The assembly model operation
+ * @return The runtime invoker
+ */
+ Invoker getInvoker(Binding binding, Operation operation);
+
+ /**
+ * Get the invoker for the given binding and operation
+ * @param binding The assembly model binding
+ * @param interfaceContract the client interface contract
+ * @param operation The assembly model operation
+ * @return The runtime invoker
+ */
+ Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation);
+
+ /**
+ * Get the invocation chain for the given binding and operation
+ * @param binding The assembly model binding
+ * @param operation The assembly model operation
+ * @return The runtime invocation chain
+ */
+ InvocationChain getInvocationChain(Binding binding, Operation operation);
+
+ /**
+ * Get the invocation chain for the given binding and operation
+ * @param binding The assembly model binding
+ * @param operation The assembly model operation
+ * @param interfaceContract the client interface contract
+ * @return The runtime invocation chain
+ */
+ InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation);
+
+ /**
+ * Add a policy provider for the given binding to the service
+ * @param binding The assembly model binding
+ * @param policyProvider The policy handler
+ */
+ void addPolicyProvider(Binding binding, PolicyProvider policyProvider);
+
+ /**
+ * Get a list of policy providers for the given binding
+ * @param binding The assembly model binding
+ * @return A list of policy providers for the given binding
+ */
+ List<PolicyProvider> getPolicyProviders(Binding binding);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java
new file mode 100644
index 0000000000..7000da9093
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.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.runtime;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+
+/**
+ * The runtime representation of a service endpoint
+ */
+public interface RuntimeEndpoint extends Endpoint, Serializable {
+ /**
+ * 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Message msg) throws InvocationTargetException;
+
+ /**
+ * 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Operation operation, Message msg) throws InvocationTargetException;
+
+ /**
+ * Attach the service binding provider
+ * @param provider
+ */
+ void setBindingProvider(ServiceBindingProvider provider);
+
+ /**
+ * Get the service binding provider
+ * @return
+ */
+ ServiceBindingProvider getBindingProvider();
+
+ /**
+ * Get a list of policy providers
+ * @return
+ */
+ List<PolicyProvider> getPolicyProviders();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java
new file mode 100644
index 0000000000..86c808c0fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.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.runtime;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+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.Message;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+
+/**
+ * The runtime representation of an endpoint reference
+ */
+public interface RuntimeEndpointReference extends EndpointReference, Serializable {
+ /**
+ * 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Message msg) throws InvocationTargetException;
+
+ /**
+ * 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Operation operation, Message msg) throws InvocationTargetException;
+
+ /**
+ * 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 list of policy providers for the endpoint reference
+ * @return A list of policy providers for the endpoint reference
+ */
+ List<PolicyProvider> getPolicyProviders();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java
new file mode 100644
index 0000000000..c0150c6138
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.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.runtime;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+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.Message;
+
+/**
+ * The runtime wire interface that connects a component reference to a
+ * component service (or an external service) over the selected binding
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeWire extends Cloneable {
+ /**
+ * return the endpoint reference that configured this wire
+ *
+ * @return the endpoint reference that configured this wire
+ */
+ EndpointReference getEndpointReference();
+
+ /**
+ * return the endpoint that configured this wire
+ *
+ * @return the endpoint that configured this wire
+ */
+ Endpoint getEndpoint();
+
+ /**
+ * Force the invocation chains to be rebuilt
+ */
+ void rebuild();
+
+ /**
+ * 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
+ */
+ 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Message msg) throws InvocationTargetException;
+
+ /**
+ * 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 message
+ * @return The result
+ * @throws InvocationTargetException
+ */
+ Object invoke(Operation operation, Message msg) throws InvocationTargetException;
+
+ /**
+ * @return a clone of the runtime wire
+ * @throws CloneNotSupportedException
+ */
+ Object clone() throws CloneNotSupportedException;
+
+ boolean isOutOfDate();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java
new file mode 100644
index 0000000000..fbb7aae467
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.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.runtime;
+
+/**
+ * Implementations are called after wires are decorated with policy and before they are connected.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeWireProcessor {
+
+ /**
+ * Process the runtime wire to add interceptors
+ *
+ * @param wire
+ */
+ void process(RuntimeWire wire);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java
new file mode 100644
index 0000000000..4b2c71b397
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java
new file mode 100644
index 0000000000..d32af450ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java
new file mode 100644
index 0000000000..6d18b48002
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java
new file mode 100644
index 0000000000..18ec2dfeaa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint
new file mode 100644
index 0000000000..dfe7f6cdde
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint
@@ -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.endpointresolver.DefaultEndpointResolverFactoryExtensionPoint
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java
new file mode 100644
index 0000000000..6486a5ed4f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/core/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/core/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5205527437
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/META-INF/MANIFEST.MF
@@ -0,0 +1,69 @@
+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.assembly.impl;version="2.0.0";scope=internal;mandatory:=scope,
+ 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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Core Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397162265
+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.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/tags/java/sca/2.0-M4-RC2/modules/core/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/core/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/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/tags/java/sca/2.0-M4-RC2/modules/core/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/core/pom.xml
new file mode 100644
index 0000000000..88a7915820
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java
new file mode 100644
index 0000000000..8c84a9e399
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
new file mode 100644
index 0000000000..ecc1a4e599
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -0,0 +1,845 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.List;
+import java.util.logging.Level;
+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.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.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.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.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.provider.BindingProviderFactory;
+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.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.runtime.CompositeActivator;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+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.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeActivatorImpl implements CompositeActivator {
+ final Logger logger = Logger.getLogger(CompositeActivatorImpl.class.getName());
+
+ private final ExtensionPointRegistry extensionPoints;
+ private final AssemblyFactory assemblyFactory;
+ private final MessageFactory messageFactory;
+ private final InterfaceContractMapper interfaceContractMapper;
+ private final ScopeRegistry scopeRegistry;
+ private final WorkScheduler workScheduler;
+ private final RuntimeWireProcessor wireProcessor;
+ private final ProviderFactoryExtensionPoint providerFactories;
+
+ public CompositeActivatorImpl(ExtensionPointRegistry extensionPoints) {
+ this.extensionPoints = extensionPoints;
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.messageFactory = factories.getFactory(MessageFactory.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.scopeRegistry = utilities.getUtility(ScopeRegistry.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.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;
+ }
+
+ /* TODO - EPR - activate services at all levels as promoted endpoin references are maintained
+ * on the higher level services
+ if (service.getService() instanceof CompositeService) {
+ return;
+ }
+ */
+
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Activating component service: " + component.getURI() + "#" + service.getName());
+ }
+
+ for (Endpoint endpoint : service.getEndpoints()) {
+ addServiceBindingProvider(endpoint, component, service, endpoint.getBinding());
+ }
+ addServiceWires(compositeContext, component, service);
+ }
+
+ public void deactivate(RuntimeComponent component, RuntimeComponentService service) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating component service: " + component.getURI() + "#" + service.getName());
+ }
+ removeServiceWires(service);
+ for (Binding binding : service.getBindings()) {
+ removeServiceBindingProvider(component, service, binding);
+ }
+ }
+
+ private ServiceBindingProvider addServiceBindingProvider(
+ Endpoint endpoint,
+ RuntimeComponent component, RuntimeComponentService service,
+ Binding binding) {
+ BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories
+ .getProviderFactory(binding.getClass());
+ if (providerFactory != null) {
+ @SuppressWarnings("unchecked")
+ ServiceBindingProvider bindingProvider = providerFactory
+ .createServiceBindingProvider(endpoint);
+ if (bindingProvider != null) {
+ ((RuntimeComponentService) service).setBindingProvider(binding,
+ bindingProvider);
+ }
+ for (PolicyProviderFactory f : providerFactories.getPolicyProviderFactories()) {
+ PolicyProvider policyProvider = f.createServicePolicyProvider(endpoint);
+ if (policyProvider != null) {
+ service.addPolicyProvider(binding, policyProvider);
+ }
+ }
+ return bindingProvider;
+ } else {
+ throw new IllegalStateException(
+ "Provider factory not found for binding: "
+ + binding.getType());
+ }
+ }
+
+ private void removeServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service, Binding binding) {
+ service.setBindingProvider(binding, null);
+ for (Binding b : service.getBindings()) {
+ List<PolicyProvider> pps = service.getPolicyProviders(b);
+ if (pps != null) {
+ pps.clear();
+ }
+ }
+ }
+
+ private void addServiceWires(CompositeContext compositeContext, Component serviceComponent, ComponentService service) {
+ if (!(service instanceof RuntimeComponentService)) {
+ return;
+ }
+
+ RuntimeComponentService runtimeService = (RuntimeComponentService)service;
+
+ // Add a wire for each service Endpoint
+ for ( Endpoint endpoint : runtimeService.getEndpoints()){
+
+ // fluff up a fake endpoint reference as we are on the service side
+ // so we need to represent the reference that will call us
+ EndpointReference endpointReference = assemblyFactory.createEndpointReference();
+ endpointReference.setBinding(endpoint.getBinding());
+ endpointReference.setTargetEndpoint(endpoint);
+ endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED);
+
+ // 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));
+ endpointReference.setInterfaceContract(getServiceBindingInterfaceContract(service, endpoint.getBinding()));
+
+ // create the wire
+ RuntimeWire wire = new RuntimeWireImpl(compositeContext,
+ false,
+ endpointReference,
+ endpoint,
+ interfaceContractMapper,
+ workScheduler,
+ wireProcessor,
+ messageFactory);
+
+ // TODO - EPR - TUSCANY-3187 - keep and eye on this as to code
+ // has been reported to be working without this fix in some
+ // environments
+ //runtimeService.getRuntimeWires().add(wire);
+ ((RuntimeComponentService)endpoint.getService()).getRuntimeWires().add(wire);
+ }
+ }
+
+ private void removeServiceWires(ComponentService service) {
+ if (!(service instanceof RuntimeComponentService)) {
+ return;
+ }
+ RuntimeComponentService runtimeService = (RuntimeComponentService)service;
+ runtimeService.getRuntimeWires().clear();
+ }
+
+ private InterfaceContract getServiceBindingInterfaceContract(ComponentService service, Binding binding) {
+ InterfaceContract interfaceContract = service.getInterfaceContract();
+
+ ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
+ if (provider != null) {
+ InterfaceContract bindingContract = provider.getBindingInterfaceContract();
+ if (bindingContract != null) {
+ interfaceContract = bindingContract;
+ }
+ }
+ return interfaceContract.makeUnidirectional(false);
+ }
+
+ // 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);
+
+ // TODO reference wires are added at component start for some reason
+ }
+
+ public void deactivate(RuntimeComponent component, RuntimeComponentReference reference) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Deactivating component reference: " + component.getURI() + "#" + reference.getName());
+ }
+ removeReferenceWires(reference);
+ for (EndpointReference endpointReference : reference.getEndpointReferences()) {
+ if (endpointReference.getBinding() != null){
+ removeReferenceBindingProvider(component, reference, endpointReference.getBinding());
+ }
+ }
+ }
+/*
+ private ReferenceBindingProvider addReferenceBindingProvider(
+ RuntimeComponent component, RuntimeComponentReference reference,
+ Binding binding) {
+ BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories
+ .getProviderFactory(binding.getClass());
+ if (providerFactory != null) {
+ @SuppressWarnings("unchecked")
+ ReferenceBindingProvider bindingProvider = providerFactory
+ .createReferenceBindingProvider(
+ (RuntimeComponent) component,
+ (RuntimeComponentReference) reference, binding);
+ if (bindingProvider != null) {
+ ((RuntimeComponentReference) reference).setBindingProvider(
+ binding, bindingProvider);
+ }
+ for (PolicyProviderFactory f : providerFactories
+ .getPolicyProviderFactories()) {
+ PolicyProvider policyProvider = f
+ .createReferencePolicyProvider(component, reference,
+ binding);
+ if (policyProvider != null) {
+ reference.addPolicyProvider(binding, policyProvider);
+ }
+ }
+
+ return bindingProvider;
+ } else {
+ throw new IllegalStateException(
+ "Provider factory not found for binding: "
+ + binding.getClass().getType());
+ }
+ }
+*/
+ private void removeReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference, Binding binding) {
+ reference.setBindingProvider(binding, null);
+ for (Binding b : reference.getBindings()) {
+ List<PolicyProvider> pps = reference.getPolicyProviders(b);
+ if (pps != null) {
+ pps.clear();
+ }
+ }
+ }
+
+ private void removeReferenceWires(ComponentReference reference) {
+ if (!(reference instanceof RuntimeComponentReference)) {
+ return;
+ }
+
+ // TODO - EPR what is this all about?
+ // [rfeng] Comment out the following statements to avoid the on-demand activation
+ // RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
+ // runtimeRef.getRuntimeWires().clear();
+ }
+
+ //=========================================================================
+ // 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);
+ }
+ }
+
+ 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();
+
+ if (implementation instanceof Composite) {
+ start(compositeContext, (Composite)implementation);
+ } else {
+ for (PolicyProvider policyProvider : runtimeComponent.getPolicyProviders()) {
+ policyProvider.start();
+ }
+ ImplementationProvider implementationProvider = runtimeComponent.getImplementationProvider();
+ if (implementationProvider != null) {
+ implementationProvider.start();
+ }
+ }
+
+ if (component instanceof ScopedRuntimeComponent) {
+ ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component;
+ if (scopedRuntimeComponent.getScopeContainer() != null) {
+ scopedRuntimeComponent.getScopeContainer().start();
+ }
+ }
+ // Reference bindings aren't started until the wire is first used
+
+ for (ComponentService service : component.getServices()) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Starting component service: " + component.getURI() + "#" + service.getName());
+ }
+ RuntimeComponentService runtimeService = (RuntimeComponentService)service;
+ for (Endpoint endpoint : service.getEndpoints()) {
+ // FIXME: Should the policy providers be started before the endpoint is started?
+ for (PolicyProvider policyProvider : runtimeService.getPolicyProviders(endpoint.getBinding())) {
+ policyProvider.start();
+ }
+
+ final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(endpoint.getBinding());
+ 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();
+ return null;
+ }
+ });
+ compositeContext.getEndpointRegistry().addEndpoint(endpoint);
+ }
+ }
+ }
+
+ runtimeComponent.setStarted(true);
+ }
+
+ 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()) {
+ compositeContext.getEndpointRegistry().removeEndpoint(endpoint);
+ final ServiceBindingProvider bindingProvider = ((RuntimeComponentService)service).getBindingProvider(endpoint.getBinding());
+ 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 : ((RuntimeComponentService)service).getPolicyProviders(endpoint
+ .getBinding())) {
+ policyProvider.stop();
+ }
+ }
+ }
+ for (ComponentReference reference : component.getReferences()) {
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("Stopping component reference: " + component.getURI() + "#" + reference.getName());
+ }
+ RuntimeComponentReference runtimeRef = ((RuntimeComponentReference)reference);
+
+ for (EndpointReference endpointReference : reference.getEndpointReferences()) {
+ compositeContext.getEndpointRegistry().removeEndpointReference(endpointReference);
+ final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding());
+ 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 : ((RuntimeComponentReference)reference)
+ .getPolicyProviders(endpointReference.getBinding())) {
+ policyProvider.stop();
+ }
+
+ }
+ }
+ 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);
+ }
+
+ // Service start/stop
+
+ // TODO - EPR done as part of the component start above
+
+ // Reference start/stop
+ // Used by component context start
+ // TODO - EPR I don't know why reference wires don't get added until component start
+
+ public void start(CompositeContext compositeContext, RuntimeComponent component, RuntimeComponentReference componentReference) {
+ synchronized (componentReference) {
+
+ if (!(componentReference instanceof RuntimeComponentReference)) {
+ return;
+ }
+
+ /* The way it was
+ // create a wire for each endpoint reference. An endpoint reference says that a
+ // target has been specified and hence the reference has been wired in some way.
+ // The service may not have been found yet, depending on the way the composite
+ // is deployed, but it is expected to be found. In the case where the reference
+ // is unwired (a target has not been specified) there will be no endpoint
+ // reference and this will lead to null being injected
+ for (EndpointReference2 endpointReference : componentReference.getEndpointReferences()){
+
+ // if there is a binding an endpoint has been found for the endpoint reference
+ if (endpointReference.getBinding() != null){
+
+ // add the binding provider. This is apparently a repeat
+ // of previous configuration as self references are created
+ // on the fly and miss the previous point where providers are added
+ RuntimeComponentReference runtimeRef = (RuntimeComponentReference)componentReference;
+
+ if (runtimeRef.getBindingProvider(endpointReference.getBinding()) == null) {
+ addReferenceBindingProvider(component, componentReference, endpointReference.getBinding());
+ }
+
+ // start the binding provider
+ final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding());
+
+ 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;
+ }
+ });
+ }
+
+ // add the wire
+ addReferenceWire(component, componentReference, endpointReference);
+ }
+ }
+ */
+
+ // 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, component, componentReference, endpointReference);
+ component.getComponentContext().getCompositeContext().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);
+ RuntimeComponent runtimeComponent = (RuntimeComponent) component;
+ EndpointRegistry endpointRegistry = runtimeComponent.getComponentContext().getCompositeContext().getEndpointRegistry();
+ for ( EndpointReference endpointReference : runtimeRef.getEndpointReferences()){
+ endpointRegistry.removeEndpointReference(endpointReference);
+ ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding());
+ if (bindingProvider != null) {
+ bindingProvider.stop();
+ }
+ for (PolicyProvider policyProvider : ((RuntimeComponentReference)reference)
+ .getPolicyProviders(endpointReference.getBinding())) {
+ policyProvider.stop();
+ }
+ }
+ }
+
+ private void addReferenceWire(CompositeContext compositeContext, Component component, ComponentReference reference, EndpointReference endpointReference) {
+ RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
+
+ // Use the interface contract of the reference on the component type and if there
+ // isn't one then use the one from the reference itself
+ Reference componentTypeRef = reference.getReference();
+
+ InterfaceContract sourceContract;
+ if (componentTypeRef == null || componentTypeRef.getInterfaceContract() == null) {
+ sourceContract = reference.getInterfaceContract();
+ } else {
+ sourceContract = componentTypeRef.getInterfaceContract();
+ }
+
+ // 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 = endpointReference.getTargetEndpoint().getInterfaceContract();
+ reference.setInterfaceContract(sourceContract);
+ }
+
+ endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
+
+/* TODO - EPR should have been done previously during matching
+ ComponentService callbackService = reference.getCallbackService();
+ if (callbackService != null) {
+ // select a reference callback binding to pass with invocations on this wire
+ Binding callbackBinding = null;
+ for (Binding binding : callbackService.getBindings()) {
+ // first look for a callback binding whose name matches the reference binding name
+ if (refBinding.getName().startsWith(binding.getName())) {
+ callbackBinding = binding;
+ break;
+ }
+ }
+ // if no callback binding found, try again based on reference binding type
+ if (callbackBinding == null) {
+ callbackBinding = callbackService.getBinding(refBinding.getClass());
+ }
+ InterfaceContract callbackContract = callbackService.getInterfaceContract();
+ EndpointReference callbackEndpoint =
+ new EndpointReferenceImpl((RuntimeComponent)refComponent, callbackService, callbackBinding,
+ callbackContract);
+ wireSource.setCallbackEndpoint(callbackEndpoint);
+ }
+*/
+
+/* TODO - EPR can't do this until the binding matches the EPR
+ InterfaceContract bindingContract = getInterfaceContract(reference, endpointReference.getBinding());
+ Endpoint2 endpoint = endpointReference.getTargetEndpoint();
+ endpoint.setInterfaceContract(bindingContract);
+*/
+
+/* TODO - EPR review in the light of new matching code
+ // TUSCANY-2029 - We should use the URI of the serviceBinding because the target may be a Component in a
+ // nested composite.
+ if (serviceBinding != null) {
+ wireTarget.setURI(serviceBinding.getURI());
+ }
+*/
+
+ // create the wire
+ // null endpoint passed in here as the endpoint reference may
+ // not be resolved yet
+ RuntimeWire wire = new RuntimeWireImpl(compositeContext,
+ true,
+ endpointReference,
+ null,
+ interfaceContractMapper,
+ workScheduler,
+ wireProcessor,
+ messageFactory);
+ runtimeRef.getRuntimeWires().add(wire);
+
+ }
+
+ private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) {
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
+ if (provider != null) {
+ InterfaceContract bindingContract = provider.getBindingInterfaceContract();
+ if (bindingContract != null) {
+ interfaceContract = bindingContract;
+ }
+ }
+ return interfaceContract.makeUnidirectional(false);
+ }
+
+
+ /* TODO - EPR - Resolved via registry now
+ public Component resolve(String componentURI) {
+ for (Composite composite : domainComposite.getIncludes()) {
+ Component component = resolve(composite, componentURI);
+ if (component != null) {
+ return component;
+ }
+ }
+ return null;
+ }
+
+
+ public Component resolve(Composite composite, String componentURI) {
+ for (Component component : composite.getComponents()) {
+ String uri = component.getURI();
+ if (uri.equals(componentURI)) {
+ return component;
+ }
+ if (componentURI.startsWith(uri)) {
+ Implementation implementation = component.getImplementation();
+ if (!(implementation instanceof Composite)) {
+ return null;
+ }
+ return resolve((Composite)implementation, componentURI);
+ }
+ }
+ return null;
+ }
+ */
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java
new file mode 100644
index 0000000000..2ad61963e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.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.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.assembly.EndpointReference;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+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 implements EndpointRegistry, LifeCycleListener {
+ private final Logger logger = Logger.getLogger(EndpointRegistryImpl.class.getName());
+
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+ private List<EndpointReference> endpointreferences = new ArrayList<EndpointReference>();
+ private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
+
+ public EndpointRegistryImpl(ExtensionPointRegistry extensionPoints, String endpointRegistryURI, String domainURI) {
+ }
+
+ public synchronized void addEndpoint(Endpoint endpoint) {
+ endpoints.add(endpoint);
+ for (EndpointListener listener : listeners) {
+ listener.endpointAdded(endpoint);
+ }
+ logger.info("Add endpoint - " + endpoint.toString());
+ }
+
+ public synchronized void addEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.add(endpointReference);
+ logger.fine("Add endpoint reference - " + endpointReference.toString());
+ }
+
+ /**
+ * Parse the component/service/binding URI into an array of parts (componentURI, serviceName, bindingName)
+ * @param uri
+ * @return
+ */
+ private String[] parse(String uri) {
+ String[] names = new String[3];
+ int index = uri.lastIndexOf('#');
+ if (index == -1) {
+ names[0] = uri;
+ } else {
+ names[0] = uri.substring(0, index);
+ String str = uri.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: " + uri);
+ }
+ names[1] = parts[0];
+ names[2] = parts[1];
+ } else if (str.startsWith("service(") && str.endsWith(")")) {
+ str = str.substring("service(".length(), str.length() - 1);
+ names[1] = str;
+ } else {
+ throw new IllegalArgumentException("Invalid component/service/binding URI: " + uri);
+ }
+ }
+ return names;
+ }
+
+ private boolean matches(String target, String uri) {
+ String[] parts1 = parse(target);
+ String[] parts2 = parse(uri);
+ for (int i = 0; i < parts1.length; i++) {
+ if (parts1[i] == null || parts1[i].equals(parts2[i])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public synchronized List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+
+ logger.fine("Find endpoint for reference - " + endpointReference.toString());
+
+ if (endpointReference.getReference() != null) {
+ Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
+ for (Endpoint endpoint : endpoints) {
+ // TODO: implement more complete matching
+ if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ }
+ // else the service name doesn't match
+ }
+ }
+
+ return foundEndpoints;
+ }
+
+ public synchronized List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ return null;
+ }
+
+ public synchronized void removeEndpoint(Endpoint endpoint) {
+ endpoints.remove(endpoint);
+ endpointRemoved(endpoint);
+ }
+
+ private void endpointRemoved(Endpoint endpoint) {
+ for (EndpointListener listener : listeners) {
+ listener.endpointRemoved(endpoint);
+ }
+ logger.info("Remove endpoint - " + endpoint.toString());
+ }
+
+ public synchronized void removeEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.remove(endpointReference);
+ logger.fine("Remove endpoint reference - " + endpointReference.toString());
+ }
+
+ public synchronized List<EndpointReference> getEndpointRefereneces() {
+ return endpointreferences;
+ }
+
+ public synchronized List<Endpoint> getEndpoints() {
+ return endpoints;
+ }
+
+ public synchronized void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ }
+
+ public synchronized List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public synchronized void removeListener(EndpointListener listener) {
+ listeners.remove(listener);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java
new file mode 100644
index 0000000000..82f8ebabea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.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.io.IOException;
+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;
+
+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 void read(Endpoint endpoint, String xml) throws IOException {
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ Endpoint result = processor.read(reader, new ProcessorContext(registry));
+ endpoint.setComponent(result.getComponent());
+ endpoint.setService(result.getService());
+ endpoint.setBinding(result.getBinding());
+ endpoint.setInterfaceContract(result.getService().getInterfaceContract());
+ } catch (Exception e) {
+ throw new IOException(e.getMessage());
+ }
+
+ }
+
+ public String write(Endpoint endpoint) throws IOException {
+ 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 IOException(e.getMessage());
+ }
+ }
+
+ public void read(EndpointReference endpointReference, String xml) throws IOException {
+ try {
+ XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
+ EndpointReference result = refProcessor.read(reader, new ProcessorContext(registry));
+ reader.close();
+ endpointReference.setComponent(result.getComponent());
+ endpointReference.setReference(result.getReference());
+ endpointReference.setBinding(result.getBinding());
+ endpointReference.setInterfaceContract(result.getReference().getInterfaceContract());
+ } catch (Exception e) {
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ public String write(EndpointReference endpointReference) throws IOException {
+ 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 IOException(e.getMessage());
+ }
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java
new file mode 100644
index 0000000000..4d6a98ca5f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java
new file mode 100644
index 0000000000..7bd56271a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
new file mode 100644
index 0000000000..6032005b9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java
new file mode 100644
index 0000000000..3fdc35a720
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.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.core.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.impl.ComponentReferenceImpl;
+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.PolicyProvider;
+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.RuntimeWire;
+
+/**
+ * Implementation of a Component Reference.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeComponentReferenceImpl extends ComponentReferenceImpl implements RuntimeComponentReference {
+ private ArrayList<RuntimeWire> wires;
+ private HashMap<Binding, ReferenceBindingProvider> bindingProviders =
+ new HashMap<Binding, ReferenceBindingProvider>();
+ private HashMap<Binding, List<PolicyProvider>> policyProviders = new HashMap<Binding, List<PolicyProvider>>();
+
+ private RuntimeComponent component;
+
+ public RuntimeComponentReferenceImpl() {
+ super();
+ }
+
+ public synchronized List<RuntimeWire> getRuntimeWires() {
+ if (wires == null) {
+ wires = new ArrayList<RuntimeWire>();
+ component.getComponentContext().start(this);
+ }
+ return wires;
+ }
+
+ // TODO - EPR - shouldn't rely on this anymore
+ public RuntimeWire getRuntimeWire(Binding binding) {
+ for (RuntimeWire wire : getRuntimeWires()) {
+ if (wire.getEndpointReference().getBinding() == binding) {
+ return wire;
+ }
+ }
+
+ return null;
+ }
+
+ public RuntimeWire getRuntimeWire(EndpointReference endpointReference) {
+ for (RuntimeWire wire : getRuntimeWires()) {
+ if (wire.getEndpointReference() == endpointReference) {
+ return wire;
+ }
+ }
+
+ return null;
+ }
+
+ public ReferenceBindingProvider getBindingProvider(Binding binding) {
+ return bindingProviders.get(binding);
+ }
+
+ public void setBindingProvider(Binding binding, ReferenceBindingProvider bindingProvider) {
+ bindingProviders.put(binding, bindingProvider);
+ }
+
+ public Invoker getInvoker(Binding binding, Operation operation) {
+ RuntimeWire wire = getRuntimeWire(binding);
+ if (wire == null) {
+ return null;
+ }
+ InvocationChain chain = wire.getInvocationChain(operation);
+ return chain == null ? null : chain.getHeadInvoker();
+ }
+
+ /**
+ * @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();
+ ref.wires = null;
+ ref.bindingProviders = new HashMap<Binding, ReferenceBindingProvider>();
+ ref.policyProviders = new HashMap<Binding, List<PolicyProvider>>();
+ return ref;
+ }
+
+ public void addPolicyProvider(Binding binding, PolicyProvider policyProvider) {
+ List<PolicyProvider> providers = policyProviders.get(binding);
+ if (providers == null) {
+ providers = new ArrayList<PolicyProvider>();
+ policyProviders.put(binding, providers);
+ }
+ providers.add(policyProvider);
+ }
+
+ public List<PolicyProvider> getPolicyProviders(Binding binding) {
+ List<PolicyProvider> providers = policyProviders.get(binding);
+ if (providers == null) {
+ return Collections.emptyList();
+ } else {
+ return providers;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java
new file mode 100644
index 0000000000..ffa488b7bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.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.core.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl;
+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.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * Implementation of a Component Service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class RuntimeComponentServiceImpl extends ComponentServiceImpl implements RuntimeComponentService {
+ private ArrayList<RuntimeWire> wires = new ArrayList<RuntimeWire>();
+ private ArrayList<RuntimeWire> callbackWires = new ArrayList<RuntimeWire>();
+ private HashMap<Binding, ServiceBindingProvider> bindingProviders = new HashMap<Binding, ServiceBindingProvider>();
+ private HashMap<Binding, List<PolicyProvider>> policyProviders = new HashMap<Binding, List<PolicyProvider>>();
+
+ public RuntimeComponentServiceImpl() {
+ super();
+ }
+
+ public List<RuntimeWire> getRuntimeWires() {
+ return wires;
+ }
+
+ public RuntimeWire getRuntimeWire(Binding binding) {
+ for (RuntimeWire wire : wires) {
+ if (wire.getEndpoint().getBinding() == binding) {
+ return wire;
+ }
+ }
+ return null;
+ }
+
+ public RuntimeWire getRuntimeWire(Binding binding, InterfaceContract interfaceContract) {
+ RuntimeWire wire = getRuntimeWire(binding);
+ if (wire == null) {
+ return null;
+ }
+ if (interfaceContract != null && interfaceContract != wire.getEndpointReference().getInterfaceContract()) {
+ try {
+ // FIXME: [rfeng] We could avoid clone() using a better comparison of the two interface contracts
+ wire = (RuntimeWire)wire.clone();
+ wire.getEndpointReference().setInterfaceContract(interfaceContract);
+ wire.rebuild();
+ } catch (CloneNotSupportedException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ return wire;
+ }
+
+ public List<RuntimeWire> getCallbackWires() {
+ return callbackWires;
+ }
+
+ public ServiceBindingProvider getBindingProvider(Binding binding) {
+ return bindingProviders.get(binding);
+ }
+
+ public void setBindingProvider(Binding binding, ServiceBindingProvider bindingProvider) {
+ bindingProviders.put(binding, bindingProvider);
+ }
+
+ public Invoker getInvoker(Binding binding, Operation operation) {
+ return getInvoker(binding, null, operation);
+ }
+
+ public Invoker getInvoker(Binding binding, InterfaceContract interfaceContract, Operation operation) {
+ InvocationChain chain = getInvocationChain(binding, interfaceContract, operation);
+ if (chain != null) {
+ return chain.getHeadInvoker();
+ } else {
+ return null;
+ }
+ }
+
+ public InvocationChain getInvocationChain(Binding binding, InterfaceContract interfaceContract, Operation operation) {
+ RuntimeWire wire = getRuntimeWire(binding);
+ if (wire == null) {
+ return null;
+ }
+ if (interfaceContract != null && interfaceContract != wire.getEndpointReference().getInterfaceContract()) {
+ try {
+ // FIXME: [rfeng] We could avoid clone() using a better comparison of the two interface contracts
+ wire = (RuntimeWire)wire.clone();
+ wire.getEndpointReference().setInterfaceContract(interfaceContract);
+ wire.rebuild();
+ } catch (CloneNotSupportedException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+ return wire.getInvocationChain(operation);
+ }
+
+ public InvocationChain getInvocationChain(Binding binding, Operation operation) {
+ return getInvocationChain(binding, null, operation);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.assembly.impl.ComponentServiceImpl#clone()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimeComponentServiceImpl clone = (RuntimeComponentServiceImpl)super.clone();
+ clone.bindingProviders = (HashMap<Binding, ServiceBindingProvider>)bindingProviders.clone();
+ clone.wires = (ArrayList<RuntimeWire>)wires.clone();
+ clone.callbackWires = (ArrayList<RuntimeWire>)callbackWires.clone();
+ clone.policyProviders = (HashMap<Binding, List<PolicyProvider>>)policyProviders.clone();
+ return clone;
+ }
+
+ public void addPolicyProvider(Binding binding, PolicyProvider policyProvider) {
+ List<PolicyProvider> providers = policyProviders.get(binding);
+ if (providers == null) {
+ providers = new ArrayList<PolicyProvider>();
+ policyProviders.put(binding, providers);
+ }
+ providers.add(policyProvider);
+ }
+
+ public List<PolicyProvider> getPolicyProviders(Binding binding) {
+ List<PolicyProvider> providers = policyProviders.get(binding);
+ if (providers == null) {
+ return Collections.emptyList();
+ } else {
+ return providers;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return getName();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
new file mode 100644
index 0000000000..357d19091b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.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.core.assembly.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointSerializer;
+
+/**
+ * Runtime model for Endpoint that supports java serialization
+ */
+public class RuntimeEndpointImpl extends EndpointImpl implements Externalizable {
+ private EndpointSerializer serializer;
+ private String bindingURI;
+ private String xml;
+
+ /**
+ * No-arg constructor for Java serilization
+ */
+ public RuntimeEndpointImpl() {
+ super(null);
+ }
+
+ public RuntimeEndpointImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.uri = in.readUTF();
+ this.xml = in.readUTF();
+ // Defer the loading to resolve();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(getURI());
+ out.writeUTF(getSerializer().write(this));
+ }
+
+ private synchronized EndpointSerializer getSerializer() {
+ if (serializer == null) {
+ if (registry != null) {
+ serializer =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(EndpointSerializer.class);
+ } else {
+ throw new IllegalStateException("No extension registry is set");
+ }
+ }
+ return serializer;
+ }
+
+ @Override
+ protected void reset() {
+ super.reset();
+ this.xml = null;
+ }
+
+ @Override
+ public void resolve() {
+ if (component == null && xml != null) {
+ try {
+ getSerializer().read(this, xml);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ super.resolve();
+ }
+
+ @Override
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ if (this.registry != registry) {
+ super.setExtensionPointRegistry(registry);
+ serializer = null;
+ }
+ // resolve();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
new file mode 100644
index 0000000000..2b1c85b95a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.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.core.assembly.impl;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.runtime.EndpointSerializer;
+
+/**
+ * Runtime model for Endpoint that supports java serialization
+ */
+public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements Externalizable {
+ private EndpointSerializer serializer;
+ private String xml;
+
+ /**
+ * No-arg constructor for Java serilization
+ */
+ public RuntimeEndpointReferenceImpl() {
+ super(null);
+ }
+
+ public RuntimeEndpointReferenceImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.uri = in.readUTF();
+ this.xml = in.readUTF();
+ // Defer the loading to resolve();
+ }
+
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeUTF(getURI());
+ out.writeUTF(getSerializer().write(this));
+ }
+
+ private synchronized EndpointSerializer getSerializer() {
+ if (serializer == null) {
+ if (registry != null) {
+ serializer =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(EndpointSerializer.class);
+ } else {
+ throw new IllegalStateException("No extension registry is set");
+ }
+ }
+ return serializer;
+ }
+
+ @Override
+ protected void reset() {
+ super.reset();
+ this.xml = null;
+ }
+
+ @Override
+ protected void resolve() {
+ if (component == null && xml != null) {
+ try {
+ getSerializer().read(this, xml);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ super.resolve();
+ }
+
+ @Override
+ public void setExtensionPointRegistry(ExtensionPointRegistry registry) {
+ if (this.registry != registry) {
+ super.setExtensionPointRegistry(registry);
+ serializer = null;
+ }
+ // resolve();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
new file mode 100644
index 0000000000..3284168aeb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
@@ -0,0 +1,787 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+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.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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.ExtensibleWireProcessor;
+import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
+import org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker;
+import org.apache.tuscany.sca.core.invocation.impl.InvocationChainImpl;
+import org.apache.tuscany.sca.core.invocation.impl.PhaseManager;
+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.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.ImplementationProvider;
+import org.apache.tuscany.sca.provider.PolicyProvider;
+import org.apache.tuscany.sca.provider.PolicyProviderFactory;
+import org.apache.tuscany.sca.provider.PolicyProviderRRB;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.provider.ReferenceBindingProviderRRB;
+import org.apache.tuscany.sca.provider.ServiceBindingProvider;
+import org.apache.tuscany.sca.provider.ServiceBindingProviderRRB;
+import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
+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.RuntimeWire;
+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.SCARuntimeException;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RuntimeWireImpl implements RuntimeWire {
+
+ private CompositeContext compositeContext;
+ private ExtensionPointRegistry extensionPoints;
+
+ private Boolean isReferenceWire = false;
+ private EndpointReference endpointReference;
+ private Endpoint endpoint;
+
+ private transient RuntimeWireProcessor wireProcessor;
+ private transient InterfaceContractMapper interfaceContractMapper;
+ private transient WorkScheduler workScheduler;
+ private transient PhaseManager phaseManager;
+ private transient MessageFactory messageFactory;
+ private transient RuntimeWireInvoker invoker;
+
+ // the following is a very simple cache that avoids re-cloning a wire
+ // when consecutive callbacks to the same endpoint are made
+ private Endpoint lastCallback;
+ private RuntimeWire cachedWire;
+ private boolean wireReserved;
+ private RuntimeWireImpl clonedFrom;
+
+ private List<InvocationChain> chains;
+ private InvocationChain bindingInvocationChain;
+
+ private EndpointReferenceBinder eprBinder;
+ private final ProviderFactoryExtensionPoint providerFactories;
+
+ /**
+ * @param source
+ * @param target
+ * @param interfaceContractMapper
+ * @param workScheduler
+ * @param wireProcessor
+ * @param messageFactory
+ * @param conversationManager
+ */
+ public RuntimeWireImpl(CompositeContext compositeContext,
+ boolean isReferenceWire,
+ EndpointReference endpointReference,
+ Endpoint endpoint,
+ InterfaceContractMapper interfaceContractMapper,
+ WorkScheduler workScheduler,
+ RuntimeWireProcessor wireProcessor,
+ MessageFactory messageFactory) {
+ super();
+ this.compositeContext = compositeContext;
+ this.extensionPoints = compositeContext.getExtensionPointRegistry();
+ this.isReferenceWire = isReferenceWire;
+ this.endpointReference = endpointReference;
+ this.endpoint = endpoint;
+ this.interfaceContractMapper = interfaceContractMapper;
+ this.workScheduler = workScheduler;
+ this.wireProcessor = wireProcessor;
+ this.messageFactory = messageFactory;
+ this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
+ this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ }
+
+ public RuntimeWireImpl(CompositeContext compositeContext,
+ boolean isReferenceWire,
+ EndpointReference endpointReference,
+ Endpoint endpoint) {
+ super();
+ this.compositeContext = compositeContext;
+ this.extensionPoints = compositeContext.getExtensionPointRegistry();
+ this.isReferenceWire = isReferenceWire;
+ this.endpointReference = endpointReference;
+ this.endpoint = endpoint;
+
+ UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+ this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ this.workScheduler = utilities.getUtility(WorkScheduler.class);
+ this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
+ FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
+ this.messageFactory = factories.getFactory(MessageFactory.class);
+ this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
+
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+ this.phaseManager = utilities.getUtility(PhaseManager.class);
+ this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+ }
+
+ public synchronized List<InvocationChain> getInvocationChains() {
+ if (chains == null) {
+ initInvocationChains();
+ }
+ return chains;
+ }
+
+ public synchronized InvocationChain getBindingInvocationChain() {
+ if (bindingInvocationChain == null) {
+ bindingInvocationChain = new InvocationChainImpl(null, null, isReferenceWire, phaseManager);
+ if (isReferenceWire) {
+ initReferenceBindingInvocationChains();
+ } else {
+ initServiceBindingInvocationChains();
+ }
+ }
+ return bindingInvocationChain;
+ }
+
+ public InvocationChain getInvocationChain(Operation operation) {
+ for (InvocationChain chain : getInvocationChains()) {
+ Operation op = null;
+ if (isReferenceWire) {
+ op = chain.getSourceOperation();
+ } else {
+ op = chain.getTargetOperation();
+ }
+ if (interfaceContractMapper.isCompatible(operation, op, op.getInterface().isRemotable())) {
+ return chain;
+ }
+ }
+ return null;
+ }
+
+ public Object invoke(Message msg) throws InvocationTargetException {
+ return getBindingInvocationChain().getHeadInvoker().invoke(msg);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ Message msg = messageFactory.createMessage();
+ msg.setBody(args);
+ return invoker.invoke(operation, msg);
+ }
+
+ public Object invoke(Operation operation, Message msg) throws InvocationTargetException {
+ 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;
+ }
+
+ private InterfaceContract getLeafInterfaceContract(EndpointReference epr) {
+ ComponentReference reference = epr.getReference();
+ if (reference == null) {
+ return epr.getInterfaceContract();
+ }
+ InterfaceContract interfaceContract = getLeafContract(reference).getInterfaceContract();
+ if (interfaceContract == null) {
+ interfaceContract = epr.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ private InterfaceContract getLeafInterfaceContract(Endpoint ep) {
+ ComponentService service = ep.getService();
+ if (service == null) {
+ return ep.getInterfaceContract();
+ }
+ InterfaceContract interfaceContract = getLeafContract(service).getInterfaceContract();
+ if (interfaceContract == null) {
+ interfaceContract = ep.getInterfaceContract();
+ }
+ return interfaceContract;
+ }
+
+ /**
+ * Initialize the invocation chains
+ */
+ private void initInvocationChains() {
+ chains = new ArrayList<InvocationChain>();
+ InterfaceContract sourceContract = endpointReference.getInterfaceContract();
+ // 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);
+
+ if (isReferenceWire) {
+ // It's the reference wire
+ resolveEndpointReference();
+
+ InterfaceContract targetContract = endpoint.getInterfaceContract();
+ // 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);
+
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ Binding refBinding = endpointReference.getBinding();
+ 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 "
+ + endpointReference.getComponent().getURI()
+ + "#"
+ + reference.getName());
+ }
+ InvocationChain chain = new InvocationChainImpl(operation, targetOperation, true, phaseManager);
+ if (operation.isNonBlocking()) {
+ addNonBlockingInterceptor(reference, refBinding, chain);
+ }
+ chains.add(chain);
+ addReferenceBindingInterceptor(reference, refBinding, chain, operation);
+ }
+
+ } else {
+ // It's the service wire
+ RuntimeComponentService service = (RuntimeComponentService)endpoint.getService();
+ RuntimeComponent serviceComponent = (RuntimeComponent)endpoint.getComponent();
+ Binding serviceBinding = endpoint.getBinding();
+ //InterfaceContract targetContract = endpoint.getInterfaceContract();
+ // 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);
+ endpoint.setInterfaceContract(targetContract);
+ 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(service, serviceBinding, chain);
+ }
+ addServiceBindingInterceptor(service, serviceBinding, chain, operation);
+ addImplementationInterceptor(serviceComponent, service, chain, targetOperation);
+ chains.add(chain);
+ }
+
+ }
+ wireProcessor.process(this);
+ }
+
+
+ /**
+ * 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(){
+ boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference);
+
+ if (!ok) {
+ throw new SCARuntimeException("Unable to bind " + endpointReference);
+ }
+
+ // set the endpoint based on the resolved endpoint
+ endpoint = endpointReference.getTargetEndpoint();
+
+ RuntimeComponentReference runtimeRef = (RuntimeComponentReference)endpointReference.getReference();
+
+ if (runtimeRef.getBindingProvider(endpointReference.getBinding()) == null) {
+ addReferenceBindingProvider(endpointReference,
+ (RuntimeComponent)endpointReference.getComponent(),
+ runtimeRef,
+ endpointReference.getBinding());
+ }
+
+ // start the binding provider
+ final ReferenceBindingProvider bindingProvider = runtimeRef.getBindingProvider(endpointReference.getBinding());
+
+ 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 : runtimeRef.getPolicyProviders(endpointReference.getBinding())) {
+ policyProvider.start();
+ }
+
+ InterfaceContract bindingContract = getInterfaceContract(endpointReference.getReference(), endpointReference.getBinding());
+ Endpoint endpoint = endpointReference.getTargetEndpoint();
+ endpoint.setInterfaceContract(bindingContract);
+ }
+
+ private ReferenceBindingProvider addReferenceBindingProvider(
+ EndpointReference endpointReference,
+ RuntimeComponent component, RuntimeComponentReference reference,
+ Binding binding) {
+ BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories
+ .getProviderFactory(binding.getClass());
+ if (providerFactory != null) {
+ @SuppressWarnings("unchecked")
+ ReferenceBindingProvider bindingProvider = providerFactory
+ .createReferenceBindingProvider(endpointReference);
+ if (bindingProvider != null) {
+ ((RuntimeComponentReference) reference).setBindingProvider(
+ binding, bindingProvider);
+ }
+ for (PolicyProviderFactory f : providerFactories
+ .getPolicyProviderFactories()) {
+ PolicyProvider policyProvider = f
+ .createReferencePolicyProvider(endpointReference);
+ if (policyProvider != null) {
+ reference.addPolicyProvider(binding, policyProvider);
+ }
+ }
+
+ return bindingProvider;
+ } else {
+ throw new IllegalStateException(
+ "Provider factory not found for binding: "
+ + binding.getType());
+ }
+ }
+
+ private InterfaceContract getInterfaceContract(ComponentReference reference, Binding binding) {
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ if (interfaceContract == null) {
+ interfaceContract = endpoint.getInterfaceContract();
+ }
+ ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
+ if (provider != null) {
+ InterfaceContract bindingContract = provider.getBindingInterfaceContract();
+ if (bindingContract != null) {
+ interfaceContract = bindingContract;
+ }
+ }
+ return interfaceContract.makeUnidirectional(false);
+ }
+
+ private void initReferenceBindingInvocationChains() {
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ Binding referenceBinding = endpointReference.getBinding();
+
+ // add the binding interceptors to the reference binding wire
+ ReferenceBindingProvider provider = reference.getBindingProvider(referenceBinding);
+ if ((provider != null) && (provider instanceof ReferenceBindingProviderRRB)) {
+ ((ReferenceBindingProviderRRB)provider).configureBindingChain(this);
+ }
+
+ // add the policy interceptors to the service binding wire
+ // find out which policies are active
+ List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(referenceBinding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ if (p instanceof PolicyProviderRRB) {
+ Interceptor interceptor = ((PolicyProviderRRB)p).createBindingInterceptor();
+ if (interceptor != null) {
+ bindingInvocationChain.addInterceptor(interceptor);
+ }
+ }
+ }
+ }
+ }
+
+ private void initServiceBindingInvocationChains() {
+ RuntimeComponentService service = (RuntimeComponentService)endpoint.getService();
+ Binding serviceBinding = endpoint.getBinding();
+
+ // add the binding interceptors to the service binding wire
+ ServiceBindingProvider provider = service.getBindingProvider(serviceBinding);
+ if ((provider != null) && (provider instanceof ServiceBindingProviderRRB)) {
+ ((ServiceBindingProviderRRB)provider).configureBindingChain(this);
+ }
+
+ // add the policy interceptors to the service binding wire
+ List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(serviceBinding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ if (p instanceof PolicyProviderRRB) {
+ Interceptor interceptor = ((PolicyProviderRRB)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);
+
+ }
+
+ // ===============================================================
+ // TODO - EPR remove when we convert fully over to EndpointReference2
+
+ // TODO - remove. Just here during development
+/*
+ static EndpointReference epr;
+
+ public EndpointReference getSource() {
+ // TODO - EPR convert this into method that returns EndpointReference2
+
+ // convert the source info into old endpoint reference format
+ epr =
+ new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(), endpointReference
+ .getReference(), endpointReference.getBinding(), endpointReference.getInterfaceContract());
+
+ if (endpointReference.getCallbackEndpoint() != null) {
+ // convert the source callback endpoint into old endpoint reference format
+ EndpointReference cepr;
+ cepr =
+ new EndpointReferenceImpl((RuntimeComponent)endpointReference.getComponent(), endpointReference
+ .getCallbackEndpoint().getService(), endpointReference.getCallbackEndpoint().getBinding(),
+ endpointReference.getCallbackEndpoint().getInterfaceContract());
+ epr.setCallbackEndpoint(cepr);
+ }
+
+ // TODO - somtimes used to reset the interface contract so we
+ // copy it back in in the rebuild method below
+ return epr;
+ }
+
+ public EndpointReference getTarget() {
+ // TODO - EPR convert this into method that returns Endpoint2
+
+ Endpoint2 endpoint = this.endpoint != null ? this.endpoint : endpointReference.getTargetEndpoint();
+
+ // convert the target info into old endpoint reference format
+ EndpointReference epr =
+ new EndpointReferenceImpl((RuntimeComponent)endpoint.getComponent(), endpoint.getService(), endpoint
+ .getBinding(), endpoint.getInterfaceContract());
+ return epr;
+ }
+
+ public void setTarget(EndpointReference target) {
+ // TODO - can we use the idea of setTarget to rebuild the wire?
+
+ }
+*/
+
+ // ===================================================================
+
+ 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;
+
+ this.endpointReference.setStatus(EndpointReference.NOT_CONFIGURED);
+
+ // TODO - cheating here as I fixed the RuntimeComponentService code
+ // to call this when it resets the interface contract
+ //endpointReference.setInterfaceContract(epr.getInterfaceContract());
+ }
+
+ public EndpointReference getEndpointReference() {
+ return endpointReference;
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ /**
+ * Add the interceptor for a reference binding
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ * @param operation
+ */
+ private void addReferenceBindingInterceptor(ComponentReference reference,
+ Binding binding,
+ InvocationChain chain,
+ Operation operation) {
+ ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
+ if (provider != null) {
+ Invoker invoker = provider.createInvoker(operation);
+ if (invoker != null) {
+ chain.addInvoker(invoker);
+ }
+ }
+ List<PolicyProvider> pps = ((RuntimeComponentReference)reference).getPolicyProviders(binding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createInterceptor(operation);
+ if (interceptor != null) {
+ chain.addInterceptor(p.createInterceptor(operation));
+ }
+ }
+ }
+ }
+
+ /**
+ * Add the interceptor for a binding
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ * @param operation
+ */
+ private void addServiceBindingInterceptor(ComponentService service,
+ Binding binding,
+ InvocationChain chain,
+ Operation operation) {
+ List<PolicyProvider> pps = ((RuntimeComponentService)service).getPolicyProviders(binding);
+ if (pps != null) {
+ for (PolicyProvider p : pps) {
+ Interceptor interceptor = p.createInterceptor(operation);
+ if (interceptor != null) {
+ chain.addInterceptor(p.createInterceptor(operation));
+ }
+ }
+ }
+ }
+
+ /**
+ * Add a non-blocking interceptor if the reference binding needs it
+ *
+ * @param reference
+ * @param binding
+ * @param chain
+ */
+ private void addNonBlockingInterceptor(ComponentReference reference, Binding binding, InvocationChain chain) {
+ ReferenceBindingProvider provider = ((RuntimeComponentReference)reference).getBindingProvider(binding);
+ if (provider != null) {
+ boolean supportsOneWayInvocation = provider.supportsOneWayInvocation();
+ if (!supportsOneWayInvocation) {
+ chain.addInterceptor(Phase.REFERENCE, new NonBlockingInterceptor(workScheduler));
+ }
+ }
+ }
+
+ /**
+ * Add a non-blocking interceptor if the service binding needs it
+ *
+ * @param service
+ * @param binding
+ * @param chain
+ */
+ private void addNonBlockingInterceptor(ComponentService service, Binding binding, InvocationChain chain) {
+ ServiceBindingProvider provider = ((RuntimeComponentService)service).getBindingProvider(binding);
+ 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));
+ }
+ }
+ }
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ RuntimeWireImpl copy = (RuntimeWireImpl)super.clone();
+ copy.endpointReference = (EndpointReference)endpointReference.clone();
+ copy.endpoint = copy.endpointReference.getTargetEndpoint();
+ copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy);
+ copy.cachedWire = null; // TUSCANY-2630
+ return copy;
+ }
+
+ public synchronized RuntimeWire lookupCache(Endpoint callback) {
+ if (lastCallback != null &&
+ callback.getURI().equals(lastCallback.getURI()) &&
+ !wireReserved) {
+ wireReserved = true;
+ return cachedWire;
+ } else {
+ return null;
+ }
+ }
+
+ public synchronized void addToCache(Endpoint callback, RuntimeWire clonedWire) {
+ ((RuntimeWireImpl)clonedWire).setClonedFrom(this);
+ lastCallback = callback;
+ cachedWire = clonedWire;
+ wireReserved = true;
+ }
+
+ public synchronized void releaseClonedWire(RuntimeWire wire) {
+ if (cachedWire == wire) {
+ wireReserved = false;
+ }
+ }
+
+ public synchronized void releaseWire() {
+ clonedFrom.releaseClonedWire(this);
+ }
+
+ private void setClonedFrom(RuntimeWireImpl wire) {
+ clonedFrom = wire;
+ }
+
+ public ExtensionPointRegistry getExtensionPoints() {
+ return extensionPoints;
+ }
+
+ /**
+ * 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 boolean isOutOfDate() {
+ return eprBinder.isOutOfDate(compositeContext.getEndpointRegistry(), getEndpointReference());
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java
new file mode 100644
index 0000000000..2de52bebb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java
new file mode 100644
index 0000000000..ace4dc48e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java
new file mode 100644
index 0000000000..9b60415132
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.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.context;
+
+import java.io.Externalizable;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Extended ServiceReference
+ */
+public interface ServiceReferenceExt<B> extends ServiceReference<B>, Externalizable {
+ /**
+ * Return the wire that sits behind this service reference
+ * @return wire
+ */
+ RuntimeWire getRuntimeWire();
+
+ /**
+ * Return the EndpointReference that sits behind this service reference
+ * @return endpoint reference
+ */
+ EndpointReference getEndpointReference();
+
+ // TODO - EPR - the the following still required?
+ /**
+ * TBD
+ *
+ * @param callbackID
+ */
+ void attachCallbackID(Object callbackID);
+
+ /**
+ * TBD
+ *
+ * @return
+ */
+ XMLStreamReader getXMLReader();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java
new file mode 100644
index 0000000000..5218a7fd01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.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.context.impl;
+
+
+import java.util.List;
+
+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.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+
+public class CallbackServiceReferenceImpl<B> extends ServiceReferenceImpl<B> {
+ private RuntimeWire wire;
+ private List<RuntimeWire> wires;
+ private Endpoint resolvedEndpoint;
+
+ /*
+ * Public constructor for Externalizable serialization/deserialization
+ */
+ public CallbackServiceReferenceImpl() {
+ super();
+ }
+
+ public CallbackServiceReferenceImpl(Class<B> interfaze, List<RuntimeWire> wires, ProxyFactory proxyFactory) {
+ super(interfaze, null, proxyFactory);
+ this.wires = wires;
+ init();
+ }
+
+ public void init() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ wire = selectCallbackWire(msgContext);
+ if (wire == null) {
+ //FIXME: need better exception
+ throw new RuntimeException("No callback binding found for " + msgContext.getTo().toString());
+ }
+ resolvedEndpoint = msgContext.getFrom().getCallbackEndpoint();
+ }
+
+ @Override
+ protected Object createProxy() throws Exception {
+ return proxyFactory.createCallbackProxy(this);
+ }
+
+ public RuntimeWire getCallbackWire() {
+ if (resolvedEndpoint == null) {
+ return null;
+ } else {
+ return cloneAndBind(wire);
+ }
+ }
+
+ public Endpoint getResolvedEndpoint() {
+ return resolvedEndpoint;
+ }
+
+ private RuntimeWire selectCallbackWire(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 RuntimeException("Destination for forward call is not available");
+ }
+ for (RuntimeWire wire : wires) {
+ if (wire.getEndpointReference().getBinding().getName().equals(to.getBinding().getName())) {
+ return wire;
+ }
+ }
+
+ // if no match, look for callback binding with same type as service binding
+ for (RuntimeWire wire : wires) {
+ if (wire.getEndpointReference().getBinding().getClass() == to.getBinding().getClass()) {
+ return wire;
+ }
+ }
+
+ // no suitable callback wire was found
+ return null;
+ }
+
+ private RuntimeWire cloneAndBind(RuntimeWire wire) {
+ RuntimeWire boundWire = null;
+ if (resolvedEndpoint != null) {
+ boundWire = ((RuntimeWireImpl)wire).lookupCache(resolvedEndpoint);
+ if (boundWire != null) {
+ return boundWire;
+ }
+ try {
+ // TODO - EPR - is this correct?
+
+ // Fluff up a new response wire based on the callback endpoint
+ RuntimeComponentReference ref =
+ bind((RuntimeComponentReference)wire.getEndpointReference().getReference(),
+ resolvedEndpoint);
+
+ boundWire = ref.getRuntimeWires().get(0);
+
+ Binding binding = wire.getEndpointReference().getBinding();
+
+ ((RuntimeWireImpl)wire).addToCache(resolvedEndpoint, boundWire);
+ } catch (CloneNotSupportedException e) {
+ // will not happen
+ }
+ }
+ return boundWire;
+ }
+
+ private RuntimeComponentReference bind(RuntimeComponentReference reference,
+ Endpoint callbackEndpoint) throws CloneNotSupportedException {
+
+ // 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();
+
+ // no access to the assembly factory so clone an existing epr
+ EndpointReference callbackEndpointReference = (EndpointReference)reference.getEndpointReferences().get(0).clone();
+
+ callbackEndpointReference.setReference(ref);
+ callbackEndpointReference.setTargetEndpoint(callbackEndpoint);
+ callbackEndpointReference.setUnresolved(true);
+
+ // TODO - should really use incoming callback info but awaiting
+ // decision from OASIS on what will happen with callbacks
+ // The callback endpoint will be resolved with the registry
+ // when the wire chains are created
+ ref.getEndpointReferences().add(callbackEndpointReference);
+
+ return ref;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
new file mode 100644
index 0000000000..4e71181747
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java
@@ -0,0 +1,496 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+import org.apache.tuscany.sca.assembly.Reference;
+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.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.monitor.Monitor;
+import org.apache.tuscany.sca.monitor.MonitorFactory;
+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.RuntimeComponentService;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * 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 Monitor monitor;
+
+ 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 = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
+ this.propertyFactory = factories.getFactory(PropertyValueFactory.class);
+
+ this.eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
+
+ MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
+ this.monitor = monitorFactory.createMonitor();
+ }
+
+ public String getURI() {
+ return component.getURI();
+ }
+
+ 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 referenceName) {
+ ServiceReference<B> serviceRef = getServiceReference(businessInterface, referenceName);
+ return serviceRef.getService();
+ }
+
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName) {
+ try {
+ for (ComponentReference ref : component.getReferences()) {
+ if (referenceName.equals(ref.getName())) {
+ /* ******************** Contribution for issue TUSCANY-2281 ******************** */
+ Multiplicity multiplicity = ref.getMultiplicity();
+ if (multiplicity == Multiplicity.ZERO_N || multiplicity == Multiplicity.ONE_N) {
+ throw new IllegalArgumentException("Reference " + referenceName
+ + " has multiplicity "
+ + multiplicity);
+ }
+ /* ******************** Contribution for issue TUSCANY-2281 ******************** */
+
+ return getServiceReference(businessInterface, (RuntimeComponentReference)ref, null);
+ }
+ }
+ throw new ServiceRuntimeException("Reference not found: " + referenceName);
+ } catch (ServiceRuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException)e;
+ }
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ /**
+ * 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 ServiceRuntimeException("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 (Exception e) {
+ throw new ServiceRuntimeException(e.getMessage(), e);
+ }
+ }
+
+ public <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName) {
+ try {
+ for (ComponentService service : component.getServices()) {
+ if (serviceName.equals(service.getName())) {
+ return createSelfReference(businessInterface, service);
+ }
+ }
+ throw new ServiceRuntimeException("Service not found: " + serviceName);
+ } 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 {
+ RuntimeComponentReference ref =
+ (RuntimeComponentReference)createSelfReference(component, service, businessInterface);
+ ref.setComponent(component);
+ return getServiceReference(businessInterface, ref, null);
+ } 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,
+ RuntimeComponentReference reference,
+ EndpointReference endpointReference) {
+ try {
+ RuntimeComponentReference ref = (RuntimeComponentReference)reference;
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ Reference componentTypeReference = reference.getReference();
+ if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
+ interfaceContract = componentTypeReference.getInterfaceContract();
+ }
+ InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
+ if (refInterfaceContract != interfaceContract) {
+ ref = (RuntimeComponentReference)reference.clone();
+ if (interfaceContract != null) {
+ ref.setInterfaceContract(interfaceContract);
+ } else {
+ ref.setInterfaceContract(refInterfaceContract);
+ }
+ }
+ ref.setComponent(component);
+ return new ServiceReferenceImpl<B>(businessInterface, component, ref, endpointReference, proxyFactory,
+ component.getComponentContext().getCompositeContext());
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Bind a component reference to a component service
+ * @param <B>
+ * @param businessInterface
+ * @param reference
+ * @param service
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface,
+ RuntimeComponentReference reference,
+ RuntimeComponent component,
+ RuntimeComponentService service) {
+ try {
+ RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
+ InterfaceContract interfaceContract = reference.getInterfaceContract();
+ Reference componentTypeReference = reference.getReference();
+ if (componentTypeReference != null && componentTypeReference.getInterfaceContract() != null) {
+ interfaceContract = componentTypeReference.getInterfaceContract();
+ }
+ InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
+ if (refInterfaceContract != interfaceContract) {
+ ref = (RuntimeComponentReference)reference.clone();
+ ref.setInterfaceContract(interfaceContract);
+ }
+ ref.getTargets().add(service);
+ ref.getBindings().clear();
+ for (Binding binding : service.getBindings()) {
+ if (binding instanceof OptimizableBinding) {
+ OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
+ optimizableBinding.setTargetBinding(binding);
+ optimizableBinding.setTargetComponent(component);
+ optimizableBinding.setTargetComponentService(service);
+ ref.getBindings().add(optimizableBinding);
+ } else {
+ ref.getBindings().add(binding);
+ }
+ }
+ return new ServiceReferenceImpl<B>(businessInterface, component, ref, null, proxyFactory, compositeContext);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public <B> ServiceReference<B> getCallableReference(Class<B> businessInterface,
+ RuntimeComponent component,
+ RuntimeComponentService service) {
+ try {
+ if (businessInterface == null) {
+ InterfaceContract contract = service.getInterfaceContract();
+ businessInterface = (Class<B>)((JavaInterface)contract.getInterface()).getJavaClass();
+ }
+ RuntimeComponentReference ref =
+ (RuntimeComponentReference)createSelfReference(component, service, businessInterface);
+ ref.setComponent(component);
+ return new ServiceReferenceImpl<B>(businessInterface, component, ref, null, proxyFactory,
+ compositeContext);
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ /**
+ * Create a self-reference for a component service
+ * @param component
+ * @param service
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private ComponentReference createSelfReference(Component component,
+ ComponentService service,
+ Class<?> businessInterface) throws CloneNotSupportedException,
+ InvalidInterfaceException {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName("$self$." + service.getName());
+
+ for (Binding binding : service.getBindings()) {
+ if (binding instanceof OptimizableBinding) {
+ OptimizableBinding optimizableBinding = (OptimizableBinding)((OptimizableBinding)binding).clone();
+ optimizableBinding.setTargetBinding(binding);
+ optimizableBinding.setTargetComponent(component);
+ optimizableBinding.setTargetComponentService(service);
+ componentReference.getBindings().add(optimizableBinding);
+ } else {
+ componentReference.getBindings().add(binding);
+ }
+ }
+
+ componentReference.setCallback(service.getCallback());
+ componentReference.getTargets().add(service);
+ componentReference.getPolicySets().addAll(service.getPolicySets());
+ componentReference.getRequiredIntents().addAll(service.getRequiredIntents());
+
+ 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.setUnresolved(false);
+ endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+
+ // create endpoint.
+ Endpoint endpoint = assemblyFactory.createEndpoint();
+ endpoint.setComponent(component);
+ endpoint.setService(service);
+ endpoint.setUnresolved(true);
+ endpointReference.setTargetEndpoint(endpoint);
+
+ componentReference.getEndpointReferences().add(endpointReference);
+
+ // do binding matching
+ boolean ok = eprBinder.bind(compositeContext.getEndpointRegistry(), endpointReference);
+
+ if (!ok) {
+ throw new SCARuntimeException("Unable to bind " + endpointReference);
+ }
+
+ return componentReference;
+ }
+
+ /**
+ * @param interfaceContract
+ * @param businessInterface
+ * @return
+ * @throws CloneNotSupportedException
+ * @throws InvalidInterfaceException
+ */
+ private InterfaceContract getInterfaceContract(InterfaceContract interfaceContract, Class<?> businessInterface)
+ throws CloneNotSupportedException, InvalidInterfaceException {
+ 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) {
+ // 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;
+ }
+
+ /**
+ * @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())) {
+ ArrayList<ServiceReference<B>> serviceRefs = new ArrayList<ServiceReference<B>>();
+ for (EndpointReference endpointReference : ref.getEndpointReferences()) {
+ serviceRefs
+ .add(getServiceReference(businessInterface, (RuntimeComponentReference)ref, endpointReference));
+ }
+ return serviceRefs;
+ }
+ }
+ throw new ServiceRuntimeException("Reference not found: " + referenceName);
+ } 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java
new file mode 100644
index 0000000000..e8a1254dc9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.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.core.context.impl;
+
+import java.util.List;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+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.core.invocation.ProxyFactoryExtensionPoint;
+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.RuntimeWire;
+import org.oasisopen.sca.RequestContext;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RequestContextImpl implements RequestContext {
+
+ private ProxyFactoryExtensionPoint proxyFactoryExtensionPoint;
+
+ public RequestContextImpl(RuntimeComponent component) {
+ ExtensionPointRegistry registry = component.getComponentContext().getExtensionPointRegistry();
+ proxyFactoryExtensionPoint = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ }
+
+ public Subject getSecuritySubject() {
+ Subject subject = null;
+
+ for (Object header : ThreadMessageContext.getMessageContext().getHeaders()){
+ if (header instanceof Subject){
+ subject = (Subject)header;
+ break;
+ }
+ }
+ return subject;
+ }
+
+ public String getServiceName() {
+ return ThreadMessageContext.getMessageContext().getTo().getService().getName();
+ }
+
+ public <B> ServiceReference<B> getServiceReference() {
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ // FIXME: [rfeng] Is this the service reference matching the caller side?
+ Endpoint to = msgContext.getTo();
+ RuntimeComponentService service = (RuntimeComponentService) to.getService();
+ RuntimeComponent component = (RuntimeComponent) to.getComponent();
+
+ ServiceReference<B> callableReference = component.getComponentContext().getCallableReference(null, component, service);
+
+ //TODO - EPR - not required for OASIS
+ //ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
+ //((CallableReferenceExt<B>) callableReference).attachCallbackID(parameters.getCallbackID());
+ //((CallableReferenceExt<B>) callableReference).attachConversation(parameters.getConversationID());
+
+ 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();
+ 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<RuntimeWire> wires = callbackReference.getRuntimeWires();
+ ProxyFactory proxyFactory = new ExtensibleProxyFactory(proxyFactoryExtensionPoint);
+ ServiceReferenceImpl ref = new CallbackServiceReferenceImpl(javaClass, wires, proxyFactory);
+ if (ref != null) {
+ //ref.resolveTarget();
+ // TODO - EPR - not required for OASIS
+ //ReferenceParameters parameters = msgContext.getFrom().getReferenceParameters();
+ //ref.attachCallbackID(parameters.getCallbackID());
+ //if (ref.getConversation() != null) {
+ // ref.attachConversationID(parameters.getConversationID());
+ //}
+ }
+ return ref;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
new file mode 100644
index 0000000000..23126b5123
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
@@ -0,0 +1,481 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.UUID;
+
+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.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.ContributionReadException;
+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.assembly.impl.ReferenceParametersImpl;
+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.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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 Object proxy;
+
+ protected Object callbackID; // The callbackID should be serializable
+
+ protected transient RuntimeComponent component;
+ protected transient RuntimeComponentReference reference;
+ protected transient EndpointReference endpointReference;
+
+ protected String scdl;
+
+ private transient XMLStreamReader xmlReader;
+
+ protected transient CompositeContext compositeContext;
+ private ExtensionPointRegistry registry;
+ private FactoryExtensionPoint modelFactories;
+ protected RuntimeAssemblyFactory assemblyFactory;
+ private StAXArtifactProcessorExtensionPoint staxProcessors;
+ private StAXArtifactProcessor<EndpointReference> staxProcessor;
+ private XMLInputFactory xmlInputFactory;
+ private XMLOutputFactory xmlOutputFactory;
+ private BuilderExtensionPoint builders;
+
+ /*
+ * Public constructor for Externalizable serialization/deserialization
+ */
+ public ServiceReferenceImpl() {
+ super();
+ }
+
+ /*
+ * Public constructor for use by XMLStreamReader2CallableReference
+ */
+ // TODO - EPR - Is this required
+ public ServiceReferenceImpl(XMLStreamReader xmlReader) throws Exception {
+ this.xmlReader = xmlReader;
+ resolve();
+ }
+
+ protected ServiceReferenceImpl(Class<B> businessInterface,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ EndpointReference endpointReference,
+ ProxyFactory proxyFactory,
+ CompositeContext compositeContext) {
+ this.proxyFactory = proxyFactory;
+ this.businessInterface = businessInterface;
+ this.component = component;
+ this.reference = reference;
+ this.endpointReference = endpointReference;
+ this.compositeContext = compositeContext;
+
+ getExtensions();
+
+ // FIXME: The SCA Specification is not clear how we should handle multiplicity
+ // for CallableReference
+ if (this.endpointReference == null) {
+
+ // TODO - EPR - If no endpoint reference specified assume the first one
+ // This will happen when a self reference is created in which case the
+ // the reference should only have one endpointReference so use that
+ if (this.reference.getEndpointReferences().size() == 0){
+ throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
+ component.getName() + " has no endpoint references");
+ }
+
+ if (this.reference.getEndpointReferences().size() > 1){
+ throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
+ component.getName() + " has more than one endpoint reference");
+ }
+
+ this.endpointReference = this.reference.getEndpointReferences().get(0);
+ }
+
+ // FIXME: Should we normalize the componentName/serviceName URI into an absolute SCA URI in the SCA binding?
+ // sca:component1/component11/component112/service1?
+ initCallbackID();
+ }
+
+ private void getExtensions() {
+ 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);
+ }
+
+ public ServiceReferenceImpl(Class<B> businessInterface, RuntimeWire wire, ProxyFactory proxyFactory) {
+ this.proxyFactory = proxyFactory;
+ this.businessInterface = businessInterface;
+ //ExtensionPointRegistry registry = ((RuntimeWireImpl)wire).getExtensionPoints();
+ //this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ //this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
+ bind(wire);
+ }
+
+ public RuntimeWire getRuntimeWire() {
+ try {
+ resolve();
+ if (endpointReference != null){
+ return reference.getRuntimeWire(endpointReference);
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public EndpointReference getEndpointReference() {
+ return endpointReference;
+ }
+
+ protected void bind(RuntimeWire wire) {
+ if (wire != null) {
+ this.component = (RuntimeComponent)wire.getEndpointReference().getComponent();
+ this.reference = (RuntimeComponentReference)wire.getEndpointReference().getReference();
+ this.endpointReference = wire.getEndpointReference();
+ this.compositeContext = component.getComponentContext().getCompositeContext();
+ initCallbackID();
+ }
+ }
+
+ protected void initCallbackID() {
+ if (reference.getInterfaceContract() != null) {
+ if (reference.getInterfaceContract().getCallbackInterface() != null) {
+ this.callbackID = createCallbackID();
+ }
+ }
+ }
+
+ public B getProxy() throws ObjectCreationException {
+ try {
+ if (proxy == null) {
+ proxy = createProxy();
+ }
+ return businessInterface.cast(proxy);
+ } catch (Exception e) {
+ throw new ObjectCreationException(e);
+ }
+ }
+
+ public void setProxy(Object proxy) {
+ this.proxy = proxy;
+ }
+
+ protected Object 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);
+ }
+ }
+
+ public boolean isConversational() {
+ try {
+ resolve();
+ return reference == null ? false : reference.getInterfaceContract().getInterface().isConversational();
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ }
+
+ public Object getCallbackID() {
+ try {
+ resolve();
+ return callbackID;
+ } 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 {
+ 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 {
+ 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
+ this.compositeContext = CompositeContext.getCurrentCompositeContext();
+ getExtensions();
+ }
+
+ streamReader = xmlInputFactory.createXMLStreamReader(reader);
+ }
+
+ endpointReference = 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) && component == null && reference == null) {
+ fromXMLString();
+
+ this.component = (RuntimeComponent)endpointReference.getComponent();
+ compositeContext.bindComponent(this.component);
+
+ this.reference = (RuntimeComponentReference)endpointReference.getReference();
+ this.reference.setComponent(this.component);
+
+ 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(component, 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();
+ ProxyFactoryExtensionPoint proxyFactories = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ return new ExtensibleProxyFactory(proxyFactories);
+ }
+
+ // ==================================================================================
+
+ /**
+ * Create a callback id
+ *
+ * @return the callback id
+ */
+ private String createCallbackID() {
+ return UUID.randomUUID().toString();
+ }
+
+ public void attachCallbackID(Object callbackID) {
+ this.callbackID = callbackID;
+ }
+
+ protected ReferenceParameters getReferenceParameters() {
+ ReferenceParameters parameters = new ReferenceParametersImpl();
+ parameters.setCallbackID(callbackID);
+ return parameters;
+ }
+
+ public XMLStreamReader getXMLReader() {
+ return xmlReader;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java
new file mode 100644
index 0000000000..2371897dce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.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;
+
+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$
+ */
+public interface InstanceWrapper<T> {
+
+ /**
+ * @return
+ */
+ T getInstance();
+
+ /**
+ * @throws TargetInitializationException
+ */
+ void start() throws TargetInitializationException;
+
+ /**
+ * @throws TargetDestructionException
+ */
+ void stop() throws TargetDestructionException;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java
new file mode 100644
index 0000000000..d35b27fd24
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.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.factory;
+
+
+/**
+ * Denotes an error creating a new object instance
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java
new file mode 100644
index 0000000000..3f64d2405b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.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.core.factory;
+
+/**
+ * Implementations create new instances of a particular type
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
new file mode 100644
index 0000000000..d4fe266d44
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.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.invocation;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.RuntimeComponentReference;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Uses a wire to return a CallableReference
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallableReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
+ private Class<?> businessInterface;
+ private RuntimeComponent component;
+ private RuntimeComponentReference reference;
+ private EndpointReference 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,
+ RuntimeComponent component,
+ RuntimeComponentReference reference,
+ EndpointReference endpointReference) {
+ this.businessInterface = businessInterface;
+ this.component = component;
+ this.reference = reference;
+ this.endpointReference = endpointReference;
+ }
+
+ public ServiceReference<?> getInstance() throws ObjectCreationException {
+ return component.getComponentContext().getServiceReference(businessInterface, reference, endpointReference);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java
new file mode 100644
index 0000000000..588eaa2d15
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java
new file mode 100644
index 0000000000..021d588cb4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.core.context.impl.CallbackServiceReferenceImpl;
+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.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Uses a wire to return a CallableReference
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
+ private Class<?> businessInterface;
+ private ProxyFactory proxyFactory;
+ private List<RuntimeWire> wires;
+
+ public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) {
+ this.businessInterface = interfaze;
+ this.proxyFactory = proxyFactory;
+ this.wires = wires;
+ }
+
+ public ServiceReference<?> getInstance() throws ObjectCreationException {
+ return new CallbackServiceReferenceImpl(businessInterface, wires, proxyFactory);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
new file mode 100644
index 0000000000..2b37c30451
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.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;
+
+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.RuntimeWire;
+
+/**
+ * Returns proxy instance for a wire callback
+ *
+ * @version $Rev$ $Date$
+ */
+public class CallbackWireObjectFactory<B> implements ObjectFactory<B> {
+ private Class<B> businessInterface;
+ private ProxyFactory proxyFactory;
+ private List<RuntimeWire> wires;
+
+ public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) {
+ this.businessInterface = interfaze;
+ this.proxyFactory = proxyFactory;
+ this.wires = wires;
+ }
+
+ public B getInstance() throws ObjectCreationException {
+ return proxyFactory.createCallbackProxy(businessInterface, wires);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
new file mode 100644
index 0000000000..11edc283a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.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.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.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.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * The implementation of a wire service that uses cglib dynamic proxies
+ *
+ * @version $Rev$ $Date$
+ */
+public class CglibProxyFactory implements ProxyFactory {
+ private MessageFactory messageFactory;
+
+ public CglibProxyFactory(MessageFactory messageFactory, InterfaceContractMapper mapper) {
+ this.messageFactory = messageFactory;
+
+ }
+
+ public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
+ 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<RuntimeWire> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), this);
+ return callbackReference != null ? createCallbackProxy(callbackReference) : null;
+ }
+
+ /**
+ * create the callback proxy with cglib. use the same
+ * JDKCallbackInvocationHandler as JDKProxyService.
+ */
+ public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException {
+ Enhancer enhancer = new Enhancer();
+ Class<T> interfaze = callbackReference.getBusinessInterface();
+ enhancer.setSuperclass(interfaze);
+ enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference));
+ Object proxy = enhancer.create();
+ callbackReference.setProxy(proxy);
+ return interfaze.cast(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(ServiceReferenceImpl<T> callbackReference) {
+ invocationHandler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
+ }
+
+ /*
+ public CglibMethodInterceptor(Class<T> interfaze, RuntimeWire wire) {
+ ServiceReference<T> serviceRef = new ServiceReferenceImpl<T>(interfaze, wire, CglibProxyFactory.this);
+ invocationHandler = new JDKInvocationHandler(messageFactory, serviceRef);
+ }
+
+ public CglibMethodInterceptor(Class<T> interfaze, List<RuntimeWire> wires) {
+ CallbackReferenceImpl ref = new CallbackReferenceImpl(interfaze, CglibProxyFactory.this, wires);
+ invocationHandler = new JDKCallbackInvocationHandler(messageFactory, ref);
+ }
+ */
+
+ /**
+ * @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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..af6f039775
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
new file mode 100644
index 0000000000..fbdfe8a8e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.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;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * An extensible proxy factory.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleProxyFactory implements ProxyFactory {
+
+ private ProxyFactoryExtensionPoint proxyFactories;
+
+ public ExtensibleProxyFactory(ProxyFactoryExtensionPoint proxyFactories) {
+ this.proxyFactories = proxyFactories;
+ }
+
+ /**
+ * @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<RuntimeWire> 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(ServiceReferenceImpl<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.RuntimeWire)
+ */
+ public <T> T createProxy(Class<T> interfaze, RuntimeWire 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
new file mode 100644
index 0000000000..934f2f7aa0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.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.invocation;
+
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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(RuntimeWire wire) {
+ for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
+ processor.process(wire);
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
new file mode 100644
index 0000000000..ec2f0a0664
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.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.core.invocation;
+
+import java.util.LinkedList;
+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.runtime.RuntimeWire;
+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 Object getBody() {
+ return null;
+ }
+
+ public void setBody(Object body) {
+ if (body != null) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ public void setCallbackWires(LinkedList<RuntimeWire> wires) {
+
+ }
+
+ 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();
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.invocation.Message#getReplyTo()
+ */
+ public EndpointReference getReplyTo() {
+ return null;
+ }
+
+ public Map<String, Object> getQoSContext() {
+ return null;
+ }
+
+ public List<Object> getHeaders() {
+ return null;
+ }
+ public <T> T getBindingContext() {
+ return null;
+ }
+
+ public <T> void setBindingContext(T bindingContext) {
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java
new file mode 100644
index 0000000000..0b36b178f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
new file mode 100644
index 0000000000..d75ff309ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+/**
+ * Creates proxies that implement Java interfaces and invocation handlers for fronting wires
+ *
+ * @version $Rev$ $Date$
+ */
+
+public interface ProxyFactory {
+
+ /**
+ * Creates a Java proxy for the given wire
+ *
+ * @param interfaze the interface the proxy implements
+ * @param wire the wire to proxy
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createProxy(Class<T> interfaze, RuntimeWire wire) 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<RuntimeWire> wires) throws ProxyCreationException;
+
+ /**
+ * Creates a Java proxy for the given callback reference
+ *
+ * @param callableReference The CallableReference
+ * @return the proxy
+ * @throws ProxyCreationException
+ */
+ <T> T createCallbackProxy(ServiceReferenceImpl<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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java
new file mode 100644
index 0000000000..875a252798
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.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.invocation;
+
+
+/**
+ * The extension point to plug in proxy factories
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
new file mode 100644
index 0000000000..43726b85dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
@@ -0,0 +1,268 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.EndpointReference;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+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.RuntimeWire;
+import org.oasisopen.sca.ServiceRuntimeException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class RuntimeWireInvoker implements Invoker{
+ protected MessageFactory messageFactory;
+ protected Object conversationID;
+ protected Object callbackID;
+ protected Object callbackObject;
+ protected RuntimeWire wire;
+
+ public RuntimeWireInvoker(MessageFactory messageFactory, RuntimeWire wire) {
+ this.messageFactory = messageFactory;
+ this.wire = wire;
+ //init(wire);
+ }
+
+ /* TODO - EPR - not required for OASIS
+ protected void init(RuntimeWire wire) {
+ if (wire != null) {
+
+ ReferenceParameters parameters = wire.getSource().getReferenceParameters();
+ this.callbackID = parameters.getCallbackID();
+ this.callbackObject = parameters.getCallbackReference();
+ this.conversationID = parameters.getConversationID();
+ InterfaceContract contract = wire.getSource().getInterfaceContract();
+ this.conversational = contract.getInterface().isConversational();
+ }
+ }
+ */
+
+ /*
+ * TODO - Introduced to allow the RuntimeWireInvoker to sit on the end of the
+ * service binding chain. Runtime wire invoke needs splitting up into
+ * separate conversation, callback interceptors etc.
+ */
+ public Message invoke(Message msg) {
+
+ try {
+ Object response = invoke(msg.getOperation(),msg);
+ // Hack to put the response back in a message.
+ // shouldn't take it out of the response message in the first place
+ msg.setBody(response);
+ } catch (InvocationTargetException e) {
+// throw new ServiceRuntimeException(e);
+ }
+
+ return msg;
+ }
+
+ public Object invoke(Operation operation, Message msg) throws InvocationTargetException {
+ return invoke(wire, operation, msg);
+ }
+
+ public Object invoke(RuntimeWire wire, Operation operation, Message msg) throws InvocationTargetException {
+ RuntimeWire runtimeWire = wire == null ? this.wire : wire;
+ InvocationChain chain = runtimeWire.getInvocationChain(operation);
+ return invoke(chain, msg, runtimeWire);
+ }
+
+ protected Object invoke(InvocationChain chain, Message msg, RuntimeWire wire) throws InvocationTargetException {
+ EndpointReference from = msg.getFrom();
+ EndpointReference epFrom = wire.getEndpointReference();
+ if (from != null) {
+ from.setComponent(epFrom.getComponent());
+ from.setReference(epFrom.getReference());
+ from.setBinding(epFrom.getBinding());
+ from.setInterfaceContract(epFrom.getInterfaceContract());
+ from.setTargetEndpoint(epFrom.getTargetEndpoint());
+ //from.setCallbackEndpoint(epFrom.getCallbackEndpoint());
+
+ // TODO - EPR - what's going on here?
+ //from.mergeEndpoint(epFrom);
+ } else {
+ msg.setFrom(epFrom);
+ }
+ msg.setTo(wire.getEndpoint());
+
+ Invoker headInvoker = chain.getHeadInvoker();
+ Operation operation = chain.getTargetOperation();
+ msg.setOperation(operation);
+
+ Message msgContext = ThreadMessageContext.getMessageContext();
+ // TODO - EPR - no required for OASIS
+ //Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID();
+
+ ThreadMessageContext.setMessageContext(msg);
+ try {
+ // TODO - EPR - no required for OASIS
+ //conversationPreinvoke(msg);
+ // handleCallback(msg, currentConversationID);
+ // dispatch the wire down the chain and get the response
+ Message resp = headInvoker.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
+ } catch (InvocationTargetException e) {
+ throw e;
+ } catch (Throwable e) {
+ throw new ServiceRuntimeException(e);
+ } finally {
+ try {
+ // TODO - EPR - no required for OASIS
+ //conversationPostInvoke(msg);
+ //} catch (TargetDestructionException e) {
+ // throw new ServiceRuntimeException(e);
+ } finally {
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+ }
+ }
+
+ /**
+ * @param msgContext
+ */
+ /* TODO - EPR - no required for OASIS
+ protected EndpointReference getCallbackEndpoint(Message msgContext) {
+ EndpointReference from = msgContext.getFrom();
+ return from == null ? null : from.getReferenceParameters().getCallbackReference();
+ }
+ */
+
+ /**
+ * Pre-invoke for the conversation handling
+ * @param msg
+ * @throws TargetResolutionException
+ */
+ /* TODO - EPR - no required for OASIS
+ private void conversationPreinvoke(Message msg) {
+ if (conversational) {
+ ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
+ // in some cases the ConversationID that should be used comes in with the
+ // message, e.g. when ws binding is in use.
+ Object convID = parameters.getConversationID();
+ if (convID != null) {
+ conversationID = convID;
+ }
+ conversation = conversationManager.getConversation(conversationID);
+
+ if (conversation == null || conversation.getState() == ConversationState.ENDED) {
+ conversation = conversationManager.startConversation(conversationID);
+ conversation.initializeConversationAttributes(wire.getTarget().getComponent());
+ } else if (conversation.conversationalAttributesInitialized() == false) {
+ conversation.initializeConversationAttributes(wire.getTarget().getComponent());
+ } else if (conversation.isExpired()){
+ throw new ConversationEndedException("Conversation has expired.");
+ }
+
+ conversation.updateLastReferencedTime();
+
+ parameters.setConversationID(conversation.getConversationID());
+ }
+ }
+ */
+
+ /**
+ * Post-invoke for the conversation handling
+ * @param wire
+ * @param operation
+ * @throws TargetDestructionException
+ */
+ /* TODO - EPR - no required for OASIS
+ @SuppressWarnings("unchecked")
+ private void conversationPostInvoke(Message msg) throws TargetDestructionException {
+ if (conversational) {
+ Operation operation = msg.getOperation();
+ ConversationSequence sequence = operation.getConversationSequence();
+ if (sequence == ConversationSequence.CONVERSATION_END) {
+ // in some cases the ConversationID that should be used comes in with the
+ // message, e.g. when ws binding is in use.
+ Object convID = msg.getFrom().getReferenceParameters().getConversationID();
+ if (convID != null) {
+ conversationID = convID;
+ }
+ conversation = conversationManager.getConversation(conversationID);
+
+ // remove conversation id from scope container
+ ScopeContainer scopeContainer = getConversationalScopeContainer(msg);
+
+ if (scopeContainer != null) {
+ scopeContainer.remove(conversation.getConversationID());
+ }
+
+ conversation.end();
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private ScopeContainer getConversationalScopeContainer(Message msg) {
+ ScopeContainer scopeContainer = null;
+
+ RuntimeComponent component = (RuntimeComponent) msg.getTo().getComponent();
+
+ if (component instanceof ScopedRuntimeComponent) {
+ ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)component;
+ ScopeContainer container = scopedRuntimeComponent.getScopeContainer();
+
+ if ((container != null) && (container.getScope() == Scope.CONVERSATION)) {
+ scopeContainer = container;
+ }
+ }
+
+ return scopeContainer;
+ }
+ */
+
+
+ /**
+ * Minimal wrapper for a callback object contained in a ServiceReference
+ */
+ private static class CallbackObjectWrapper<T> implements InstanceWrapper<T> {
+
+ private T instance;
+
+ private CallbackObjectWrapper(T instance) {
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+ public void start() {
+ // do nothing
+ }
+
+ public void stop() {
+ // do nothing
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java
new file mode 100644
index 0000000000..2fc3d6c7eb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.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.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.RuntimeWire;
+
+/**
+ * Uses a wire to return an object instance
+ *
+ * @version $Rev$ $Date$
+ */
+public class WireObjectFactory<T> implements ObjectFactory<T> {
+ private Class<T> interfaze;
+ private RuntimeWire 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, RuntimeWire wire, ProxyFactory proxyService) {
+ this.interfaze = interfaze;
+ this.wire = wire;
+ this.proxyService = proxyService;
+ }
+
+ public T getInstance() throws ObjectCreationException {
+ return new ServiceReferenceImpl<T>(interfaze, wire, proxyService).getProxy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java
new file mode 100644
index 0000000000..aeccfa8b05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.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 java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.oasisopen.sca.ServiceReference;
+
+public class AsyncJDKInvocationHandler extends JDKInvocationHandler {
+ private static final long serialVersionUID = 1L;
+
+ public AsyncJDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
+ super(messageFactory, callableReference);
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (isAsyncCallback(method)) {
+ return doInvokeAsyncCallback(proxy, method, args);
+ } else if (isAsyncPoll(method)) {
+ return doInvokeAsyncPoll(proxy, method, args);
+ } else {
+ return super.invoke(proxy, method, args);
+ }
+ }
+
+ 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;
+ }
+
+ protected boolean isAsyncPoll(Method method) {
+ return method.getName().endsWith("Async") && (method.getReturnType().isAssignableFrom(Response.class));
+ }
+
+ protected AsyncResponse doInvokeAsyncPoll(Object proxy, Method asyncMethod, Object[] args) {
+ Object response;
+ boolean isException;
+ try {
+ response = super.invoke(proxy, getNonAsyncMethod(asyncMethod), args);
+ isException = false;
+ } catch (Throwable e) {
+ response = e;
+ isException = true;
+ }
+ return new AsyncResponse(response, isException);
+ }
+
+ 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));
+ handler.handleResponse(response);
+
+ return null;
+ }
+
+ 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 non-async method matching async method " + asyncMethod.getName());
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java
new file mode 100644
index 0000000000..07086dfae3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
new file mode 100644
index 0000000000..60914f799b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.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.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();
+ }
+
+ /**
+ * @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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
new file mode 100644
index 0000000000..e64b9f3068
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.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.invocation.impl;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
+import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
+import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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, ServiceReferenceImpl 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
+ RuntimeWire wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackWire();
+ 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, wire.getEndpointReference());
+ } catch (InvocationTargetException e) {
+ Throwable t = e.getCause();
+ throw e;
+ } finally {
+ // allow the cloned wire to be reused by subsequent callbacks
+ ((RuntimeWireImpl)wire).releaseWire();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
new file mode 100644
index 0000000000..148749922e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -0,0 +1,537 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.context.ThreadMessageContext;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
+import org.apache.tuscany.sca.core.factory.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.TargetResolutionException;
+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.RuntimeWire;
+import org.oasisopen.sca.SCARuntimeException;
+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 boolean conversational;
+ protected MessageFactory messageFactory;
+ protected EndpointReference source;
+ protected Endpoint target;
+ protected RuntimeWire wire;
+ protected ServiceReferenceExt<?> callableReference;
+ protected Class<?> businessInterface;
+
+ protected boolean fixedWire = true;
+
+ protected transient Map<Method, InvocationChain> chains = new HashMap<Method, InvocationChain>();
+
+ public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeWire wire) {
+ this.messageFactory = messageFactory;
+ this.wire = wire;
+ this.businessInterface = businessInterface;
+ init(this.wire);
+ }
+
+ public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
+ this.messageFactory = messageFactory;
+ this.callableReference = (ServiceReferenceExt<?>)callableReference;
+ if (callableReference != null) {
+ this.businessInterface = callableReference.getBusinessInterface();
+ this.wire = ((ServiceReferenceExt<?>)callableReference).getRuntimeWire();
+ if (wire != null) {
+ init(wire);
+ }
+ }
+ }
+
+ protected void init(RuntimeWire wire) {
+ // TODO - EPR not required for OASIS
+ /*
+ if (wire != null) {
+ try {
+ // Clone the endpoint reference so that reference parameters can be changed
+ source = (EndpointReference)wire.getSource().clone();
+ } catch (CloneNotSupportedException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ initConversational(wire);
+ }
+ */
+ }
+
+ /* TODO - EPR - not required for OASIS
+ protected void initConversational(RuntimeWire wire) {
+ InterfaceContract contract = wire.getSource().getInterfaceContract();
+ this.conversational = contract.getInterface().isConversational();
+ }
+ */
+
+ public Class<?> getBusinessInterface() {
+ return businessInterface;
+ }
+
+
+ protected Object getCallbackID() {
+// if (callableReference != null) {
+// return callableReference.getCallbackID();
+// } else {
+ return null;
+// }
+ }
+
+ /* TODO - EPR - Not reqiured for OASIS
+ protected Object getCallbackObject() {
+ if (callableReference != null && callableReference instanceof ServiceReference) {
+ return ((ServiceReference)callableReference).getService();
+ } else {
+ return null;
+ }
+ }
+ */
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (Object.class == method.getDeclaringClass()) {
+ return invokeObjectMethod(method, args);
+ }
+ if (wire == null) {
+ throw new ServiceRuntimeException("No runtime wire is available");
+ }
+
+ if (wire.isOutOfDate()) {
+ wire.rebuild();
+ chains.clear();
+ }
+
+ InvocationChain chain = getInvocationChain(method, wire);
+
+ if (chain == null) {
+ throw new IllegalArgumentException("No matching operation is found: " + method);
+ }
+
+ // The EndpointReference is not now resolved until the invocation chain
+ // is first created so reset the source here
+ source = wire.getEndpointReference();
+
+ // send the invocation down the wire
+ Object result = invoke(chain, args, wire, 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, RuntimeWire wire) {
+ if (fixedWire && chains.containsKey(method)) {
+ return chains.get(method);
+ }
+ InvocationChain found = null;
+ for (InvocationChain chain : wire.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, RuntimeWire wire, EndpointReference source)
+ throws Throwable {
+ Message msg = messageFactory.createMessage();
+ msg.setFrom(source);
+ if (target != null) {
+ msg.setTo(target);
+ } else {
+ msg.setTo(wire.getEndpoint());
+ }
+ Invoker headInvoker = chain.getHeadInvoker();
+ Operation operation = chain.getTargetOperation();
+ msg.setOperation(operation);
+ msg.setBody(args);
+
+ Message msgContext = ThreadMessageContext.getMessageContext();
+
+ // TODO - EPR - not required for OASIS
+ //Object currentConversationID = msgContext.getFrom().getReferenceParameters().getConversationID();
+ //conversationPreinvoke(msg, wire);
+
+ handleCallback(msg, wire);
+ ThreadMessageContext.setMessageContext(msg);
+ boolean abnormalEndConversation = false;
+ try {
+ // dispatch the wire down the chain and get the response
+ Message resp = headInvoker.invoke(msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ /* TODO - EPR - not required in OASIS
+ // mark the conversation as ended if the exception is not a business exception
+ if (currentConversationID != null ){
+ try {
+ boolean businessException = false;
+
+ for (DataType dataType : operation.getFaultTypes()){
+ if (dataType.getPhysical() == ((Throwable)body).getClass()){
+ businessException = true;
+ break;
+ }
+ }
+
+ if (businessException == false){
+ abnormalEndConversation = true;
+ }
+ } catch (Exception ex){
+ // TODO - sure what the best course of action is here. We have
+ // a system exception in the middle of a business exception
+ }
+ }
+ */
+ throw (Throwable)body;
+ }
+ return body;
+ } finally {
+ //conversationPostInvoke(msg, wire, abnormalEndConversation);
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+ }
+
+ /**
+ * @param msg
+ * @param wire
+ * @param interfaze
+ * @throws TargetResolutionException
+ */
+ private void handleCallback(Message msg, RuntimeWire wire)
+ throws TargetResolutionException {
+
+ //ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
+ //parameters.setCallbackID(getCallbackID());
+
+ if (msg.getFrom() == null || msg.getFrom().getCallbackEndpoint() == null) {
+ return;
+ }
+
+ /* TODO - EPR - not required for OASIS
+ parameters.setCallbackReference(msg.getFrom().getCallbackEndpoint());
+
+ // If we are passing out a callback target
+ // register the calling component instance against this
+ // new conversation id so that stateful callbacks will be
+ // able to find it
+ Object callbackObject = getCallbackObject();
+ if (conversational && callbackObject == null) {
+ // the component instance is already registered
+ // so add another registration
+ ScopeContainer<Object> scopeContainer = getConversationalScopeContainer(wire);
+
+ if (scopeContainer != null && currentConversationID != null) {
+ scopeContainer.addWrapperReference(currentConversationID, conversation.getConversationID());
+ }
+ }
+
+ Interface interfaze = msg.getFrom().getCallbackEndpoint().getInterfaceContract().getInterface();
+ if (callbackObject != null) {
+ if (callbackObject instanceof ServiceReference) {
+ CallableReferenceExt<?> callableReference = (CallableReferenceExt<?>)callbackObject;
+ EndpointReference callbackRef = callableReference.getEndpointReference();
+
+ // TODO - EPR - create chains on the callback reference in case this hasn't already happened
+ // needed as the bindings are not now matched until the chanins are created
+ callableReference.getRuntimeWire().getInvocationChains();
+
+ parameters.setCallbackReference(callbackRef);
+ } else {
+ if (interfaze != null) {
+ if (!interfaze.isConversational()) {
+ throw new IllegalArgumentException(
+ "Callback object for stateless callback is not a ServiceReference");
+ } else {
+ if (!(callbackObject instanceof Serializable)) {
+ throw new IllegalArgumentException(
+ "Callback object for stateful callback is not Serializable");
+ }
+ ScopeContainer scopeContainer = getConversationalScopeContainer(wire);
+ if (scopeContainer != null) {
+ InstanceWrapper wrapper = new CallbackObjectWrapper(callbackObject);
+ scopeContainer.registerWrapper(wrapper, conversation.getConversationID());
+ }
+ parameters.setCallbackObjectID(callbackObject);
+ }
+ }
+ }
+ }
+ */
+ }
+
+ /**
+ * Pre-invoke for the conversation handling
+ * @param msg
+ * @throws TargetResolutionException
+ */
+ /* TODO - EPR - not required for OASIS
+ private void conversationPreinvoke(Message msg, RuntimeWire wire) {
+ if (!conversational) {
+ // Not conversational or the conversation has been started
+ return;
+ }
+
+ ConversationManager conversationManager = ((RuntimeWireImpl2)wire).getConversationManager();
+
+ if (conversation == null || conversation.getState() == ConversationState.ENDED) {
+
+ conversation = conversationManager.startConversation(getConversationID());
+
+ // if this is a local wire then set up the conversation timeouts here based on the
+ // parameters from the component
+ if (wire.getEndpoint().getComponent() != null){
+ conversation.initializeConversationAttributes((RuntimeComponent)wire.getEndpoint().getComponent());
+ }
+
+ // connect the conversation to the CallableReference so it can be retrieve in the future
+ if (callableReference != null) {
+ ((CallableReferenceImpl)callableReference).attachConversation(conversation);
+ }
+ } else if (conversation.isExpired()) {
+ throw new ConversationEndedException("Conversation " + conversation.getConversationID() + " has expired.");
+ }
+
+ // if this is a local wire then schedule conversation timeouts based on the timeout
+ // parameters from the service implementation. If this isn't a local wire then
+ // the RuntimeWireInvoker will take care of this
+ if (wire.getEndpoint().getComponent() != null){
+ conversation.updateLastReferencedTime();
+ }
+
+ msg.getFrom().getReferenceParameters().setConversationID(conversation.getConversationID());
+
+ }
+ */
+
+ /**
+ * Post-invoke for the conversation handling
+ * @param wire
+ * @param operation
+ * @throws TargetDestructionException
+ */
+ /* TODO - not required for OASIS
+ @SuppressWarnings("unchecked")
+ private void conversationPostInvoke(Message msg, RuntimeWire wire, boolean abnormalEndConversation)
+ throws TargetDestructionException {
+ Operation operation = msg.getOperation();
+ ConversationSequence sequence = operation.getConversationSequence();
+ // We check that conversation has not already ended as there is only one
+ // conversation manager in the runtime and so, in the case of remote bindings,
+ // the conversation will already have been stopped when we get back to the client
+ if ((sequence == ConversationSequence.CONVERSATION_END || abnormalEndConversation) &&
+ (conversation.getState() != ConversationState.ENDED)) {
+
+ // remove conversation id from scope container
+ ScopeContainer scopeContainer = getConversationalScopeContainer(wire);
+
+ if (scopeContainer != null) {
+ scopeContainer.remove(conversation.getConversationID());
+ }
+
+ conversation.end();
+ }
+ }
+
+
+ private ScopeContainer<Object> getConversationalScopeContainer(RuntimeWire wire) {
+ ScopeContainer<Object> scopeContainer = null;
+
+ RuntimeComponent runtimeComponent = (RuntimeComponent)wire.getEndpointReference().getComponent();
+
+ if (runtimeComponent instanceof ScopedRuntimeComponent) {
+ ScopedRuntimeComponent scopedRuntimeComponent = (ScopedRuntimeComponent)runtimeComponent;
+ ScopeContainer<Object> tmpScopeContainer = scopedRuntimeComponent.getScopeContainer();
+
+ if ((tmpScopeContainer != null) && (tmpScopeContainer.getScope() == Scope.CONVERSATION)) {
+ scopeContainer = tmpScopeContainer;
+ }
+ }
+
+ return scopeContainer;
+ }
+ */
+
+ /**
+ * Creates a new conversation id
+ *
+ * @return the conversation id
+ */
+ /* TODO - EPR - not required for OASIS
+ private Object createConversationID() {
+ if (getConversationID() != null) {
+ return getConversationID();
+ } else {
+ return UUID.randomUUID().toString();
+ }
+ }
+ */
+
+ /**
+ * @return the callableReference
+ */
+ public ServiceReference<?> getCallableReference() {
+ return callableReference;
+ }
+
+ /**
+ * @param callableReference the callableReference to set
+ */
+ public void setCallableReference(ServiceReference<?> callableReference) {
+ this.callableReference = (ServiceReferenceExt<?>)callableReference;
+ }
+
+ /**
+ * Minimal wrapper for a callback object contained in a ServiceReference
+ */
+ private static class CallbackObjectWrapper<T> implements InstanceWrapper<T> {
+
+ private T instance;
+
+ private CallbackObjectWrapper(T instance) {
+ this.instance = instance;
+ }
+
+ public T getInstance() {
+ return instance;
+ }
+
+ public void start() {
+ // do nothing
+ }
+
+ public void stop() {
+ // do nothing
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
new file mode 100644
index 0000000000..853e28fafa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.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.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.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.RuntimeWire;
+import org.oasisopen.sca.ServiceReference;
+
+
+/**
+ * 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(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
+ return createProxy(serviceReference);
+ }
+
+ public <T> T createProxy(ServiceReference<T> callableReference) throws ProxyCreationException {
+ assert callableReference != null;
+ final Class<T> interfaze = callableReference.getBusinessInterface();
+ InvocationHandler handler;
+ 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();
+ }
+ });
+ Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler);
+ ((ServiceReferenceImpl)callableReference).setProxy(proxy);
+ return interfaze.cast(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<RuntimeWire> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires, this);
+ return callbackReference != null ? createCallbackProxy(callbackReference) : null;
+ }
+
+ public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException {
+ assert callbackReference != null;
+ Class<T> interfaze = callbackReference.getBusinessInterface();
+ InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
+ ClassLoader cl = interfaze.getClassLoader();
+ Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler);
+ callbackReference.setProxy(proxy);
+ return interfaze.cast(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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java
new file mode 100644
index 0000000000..6ce2ffca21
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java
new file mode 100644
index 0000000000..53fab3392c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.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.core.invocation.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+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 List<Object> headers = new ArrayList<Object>();
+ private Object body;
+ private Object messageID;
+ private boolean isFault;
+ private Operation operation;
+
+ private EndpointReference from;
+ private Endpoint to;
+
+ private Object bindingContext;
+
+ public MessageImpl() {
+ // TODO - EPR - What to do by default?
+ //this.from = new EndpointReferenceImpl("/");
+ //this.to = new EndpointReferenceImpl("/");
+ 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 List<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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java
new file mode 100644
index 0000000000..45f4bf52bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
new file mode 100644
index 0000000000..1649eade87
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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_INTERFACE, REFERENCE_POLICY, 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_POLICY, SERVICE_INTERFACE, 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java
new file mode 100644
index 0000000000..175f3463ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java
new file mode 100644
index 0000000000..3240b4e50d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.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.core.runtime;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+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;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+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 DefaultDomainRegistryFactory implements DomainRegistryFactory, LifeCycleListener {
+ private ExtensionPointRegistry extensionRegistry;
+ private Map<String, ServiceDeclaration> declarations = new HashMap<String, ServiceDeclaration>();
+ private Map<String, EndpointRegistry> endpointRegistries = new ConcurrentHashMap<String, EndpointRegistry>();
+ private List<EndpointListener> listeners = new ArrayList<EndpointListener>();
+
+ /**
+ * @param extensionRegistry
+ */
+ public DefaultDomainRegistryFactory(ExtensionPointRegistry extensionRegistry) {
+ super();
+ this.extensionRegistry = extensionRegistry;
+ }
+
+ public void start() {
+ Collection<ServiceDeclaration> sds = null;
+ try {
+ sds = extensionRegistry.getServiceDiscovery().getServiceDeclarations(EndpointRegistry.class);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ for (ServiceDeclaration sd : sds) {
+ String scheme = sd.getAttributes().get("scheme");
+ if (scheme != null) {
+ scheme = scheme.toLowerCase();
+ }
+ declarations.put(scheme, sd);
+ }
+ }
+
+ public synchronized EndpointRegistry getEndpointRegistry(String endpointRegistryURI, String domainURI) {
+ if (endpointRegistryURI == null) {
+ endpointRegistryURI = "vm://localhost";
+ }
+
+ String key = endpointRegistryURI + "," + domainURI;
+
+ EndpointRegistry endpointRegistry = endpointRegistries.get(key);
+ if (endpointRegistry != null) {
+ return endpointRegistry;
+ }
+
+ URI uri = URI.create(endpointRegistryURI);
+ String scheme = uri.getScheme();
+ if (scheme != null) {
+ scheme = scheme.toLowerCase();
+ }
+
+ ServiceDeclaration sd = declarations.get(scheme);
+
+ try {
+ Class<?> implClass = sd.loadClass();
+ Constructor<?> constructor = null;
+ try {
+ constructor = implClass.getConstructor(ExtensionPointRegistry.class, String.class, String.class);
+ endpointRegistry =
+ (EndpointRegistry)constructor.newInstance(extensionRegistry, endpointRegistryURI, domainURI);
+ } catch (NoSuchMethodException e) {
+ constructor =
+ implClass.getConstructor(ExtensionPointRegistry.class, Map.class, String.class, String.class);
+ endpointRegistry =
+ (EndpointRegistry)constructor.newInstance(extensionRegistry,
+ sd.getAttributes(),
+ endpointRegistryURI,
+ domainURI);
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ if (endpointRegistry instanceof LifeCycleListener) {
+ ((LifeCycleListener)endpointRegistry).start();
+ }
+
+ for (EndpointListener listener : listeners) {
+ endpointRegistry.addListener(listener);
+ }
+ endpointRegistries.put(key, endpointRegistry);
+ return endpointRegistry;
+ }
+
+ public void stop() {
+ declarations.clear();
+ 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
new file mode 100644
index 0000000000..bab83bad2d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.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.core.runtime.impl;
+
+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.core.UtilityExtensionPoint;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+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.runtime.EndpointReferenceBinder;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * An 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 builder in case it is required by undresolved endpoints
+ * once the runtime has started.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EndpointReferenceBinderImpl implements EndpointReferenceBinder {
+
+ protected ExtensionPointRegistry extensionPoints;
+ protected AssemblyFactory assemblyFactory;
+ protected InterfaceContractMapper interfaceContractMapper;
+ private 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();
+ }
+
+
+
+ /**
+ * Build a single endpoint reference
+ *
+ * @param endpoint
+ * @param monitor
+ */
+ public boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
+ Problem problem = null;
+ if ( endpointReference.getStatus() == EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED ||
+ endpointReference.getStatus() == EndpointReference.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() == true ){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+ } else if (endpointReference.getStatus() == EndpointReference.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.
+
+ problem = selectForwardEndpoint(endpointReference,
+ endpointReference.getTargetEndpoint().getService().getEndpoints());
+
+ if (problem == null && hasCallback(endpointReference)){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+
+ } else if (endpointReference.getStatus() == EndpointReference.WIRED_TARGET_NOT_FOUND ||
+ endpointReference.getStatus() == EndpointReference.NOT_CONFIGURED){
+ // The service is in a remote composite somewhere else in the domain
+
+ // find the service in the endpoint registry
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+
+ if (endpoints.size() == 0) {
+ problem = monitor.createProblem(this.getClass().getName(),
+ "endpoint-validation-messages",
+ Problem.Severity.ERROR,
+ this,
+ "NoEndpointsFound",
+ endpointReference.toString());
+ }
+
+ problem = selectForwardEndpoint(endpointReference,
+ endpoints);
+
+ if (problem == null && hasCallback(endpointReference)){
+ problem = selectCallbackEndpoint(endpointReference,
+ endpointReference.getReference().getCallbackService().getEndpoints());
+ }
+ }
+
+ if (problem != null){
+ monitor.problem(problem);
+ return false;
+ }
+
+ if (endpointReference.getStatus() != EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED &&
+ endpointReference.getStatus() != EndpointReference.RESOLVED_BINDING){
+ problem = monitor.createProblem(this.getClass().getName(),
+ "endpoint-validation-messages",
+ Problem.Severity.ERROR,
+ this,
+ "EndpointReferenceCantBeMatched",
+ endpointReference.toString());
+ monitor.problem(problem);
+ return false;
+ }
+
+ return true;
+
+ }
+
+ private Problem selectForwardEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
+
+ 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)){
+ matchedEndpoint = endpoint;
+ break;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null){
+ return null;
+ }
+
+ endpointReference.setTargetEndpoint(matchedEndpoint);
+ endpointReference.setBinding(endpointReference.getTargetEndpoint().getBinding());
+ endpointReference.setStatus(EndpointReference.WIRED_TARGET_FOUND_AND_MATCHED);
+ endpointReference.setUnresolved(false);
+
+ return null;
+ }
+
+ 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;
+ }
+ }
+
+ private Problem selectCallbackEndpoint(EndpointReference endpointReference, List<Endpoint> endpoints) {
+
+ Problem problem = null;
+
+ // find the first callback endpoint that matches a callback endpoint reference
+ // at the service
+ Endpoint matchedEndpoint = null;
+ match:
+ for ( EndpointReference callbackEndpointReference : endpointReference.getTargetEndpoint().getCallbackEndpointReferences()){
+ for (Endpoint endpoint : endpoints){
+ if (haveMatchingPolicy(callbackEndpointReference, endpoint)){
+ matchedEndpoint = endpoint;
+ break match;
+ }
+ }
+ }
+
+ if (matchedEndpoint == null){
+ return null;
+ }
+
+ endpointReference.setCallbackEndpoint(matchedEndpoint);
+
+ return problem;
+ }
+
+ // FIXME: [rfeng] This implementation is wrong. It is the responsibility of the policy language
+ // to compare the reference and service side setting to determine if they are compatible. Some of
+ // policies apply to the reference side only, some of the policies apply to the service side only,
+ // while others apply to both sides. Even for those policies that apply to both side, they can be
+ // independent or related.
+ private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint){
+
+ /*
+ // if no policy sets or intents are present then they match
+ if ((endpointReference.getRequiredIntents().size() == 0) &&
+ (endpoint.getRequiredIntents().size() == 0) &&
+ (endpointReference.getPolicySets().size() == 0) &&
+ (endpoint.getPolicySets().size() == 0)) {
+ return true;
+ }
+
+ // if there are different numbers of intents
+ // then they don't match
+ if (endpointReference.getRequiredIntents().size() !=
+ endpoint.getRequiredIntents().size()) {
+ return false;
+ }
+
+ // if there are different numbers of policy sets
+ // then they don't match
+ if (endpointReference.getPolicySets().size() !=
+ endpoint.getPolicySets().size()) {
+ return false;
+ }
+
+ // check intents for compatibility
+ for(Intent intentEPR : endpointReference.getRequiredIntents()){
+ boolean matched = false;
+ for (Intent intentEP : endpoint.getRequiredIntents()){
+ if (intentEPR.getName().equals(intentEP.getName())){
+ matched = true;
+ break;
+ }
+ }
+ if (matched == false){
+ return false;
+ }
+ }
+
+ // check policy sets for compatibility. The list of policy sets
+ // may be a subset of the list of intents as some of the intents
+ // may be directly provided. We can't just rely on intent compatibility
+ // as different policy sets might have been attached at each end to
+ // satisfy the listed intents
+
+ // if all of the policy sets on the endpoint reference match a
+ // policy set on the endpoint then they match
+ for(PolicySet policySetEPR : endpointReference.getPolicySets()){
+ boolean matched = false;
+ for (PolicySet policySetEP : endpoint.getPolicySets()){
+ // find if there is a policy set with the same name
+ if (policySetEPR.getName().equals(policySetEP.getName())){
+ matched = true;
+ break;
+ }
+ // find if the policies inside the policy set match the
+ // policies inside a policy set on the endpoint
+
+ // TODO - need a policy specific matcher to do this
+ // so need a new extension point
+
+ }
+
+ if (matched == false){
+ return false;
+ }
+ }
+ */
+
+ return true;
+ }
+
+ public boolean isOutOfDate(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
+ Endpoint te = endpointReference.getTargetEndpoint();
+ if (!te.isUnresolved() && te.getURI()!= null) {
+ List<Endpoint> endpoints = endpointRegistry.findEndpoint(endpointReference);
+ return ! endpoints.contains(endpointReference.getTargetEndpoint());
+ }
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java
new file mode 100644
index 0000000000..4674456925
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
new file mode 100644
index 0000000000..2ea724ccf6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java
new file mode 100644
index 0000000000..0a7f2ef64f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.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.core.scope;
+
+/**
+ * The default implementation scopes supported by assemblies.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java
new file mode 100644
index 0000000000..2398ecea3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.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.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.
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java
new file mode 100644
index 0000000000..b19c14b3e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java
new file mode 100644
index 0000000000..842ed4c547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java
new file mode 100644
index 0000000000..30d5c77181
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.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.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$
+ */
+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();
+
+ /**
+ * @return the maxAge
+ */
+ long getMaxAge();
+
+ /**
+ * @return the maxIdleTime
+ */
+ long getMaxIdleTime();
+
+ /**
+ * Create a wrapper for the component instance for the scope management
+ *
+ * @return A wrapper for the component instance
+ */
+ InstanceWrapper createInstanceWrapper();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java
new file mode 100644
index 0000000000..c27b112f8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.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.runtime.RuntimeComponent;
+
+/**
+ * Scoped runtime component
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java
new file mode 100644
index 0000000000..0f83dad97d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.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;
+
+/**
+ * Denotes an error destroying a target
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java
new file mode 100644
index 0000000000..15959c0608
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.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;
+
+/**
+ * Denotes an error initializing a target
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java
new file mode 100644
index 0000000000..bb46a2499b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java
new file mode 100644
index 0000000000..ea8d0e876c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.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;
+
+/**
+ * Denotes an error retrieving a target instance
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java
new file mode 100644
index 0000000000..730f92e0f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java
new file mode 100644
index 0000000000..f61e70a598
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java
new file mode 100644
index 0000000000..9884c5f053
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java
new file mode 100644
index 0000000000..1235fd2a67
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java
new file mode 100644
index 0000000000..5bf20a6a5f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java
new file mode 100644
index 0000000000..9e6f3b3087
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.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.core.work.impl;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+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;
+
+ /**
+ * Initializes the JSR 237 work manager.
+ *
+ * @param jsr237WorkManager JSR 237 work manager.
+ */
+ public DefaultWorkScheduler() {
+ }
+
+ 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(0);
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java
new file mode 100644
index 0000000000..e7728ca9a9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+ }
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java
new file mode 100644
index 0000000000..ca06d0e854
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java
new file mode 100644
index 0000000000..4580011806
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java
new file mode 100644
index 0000000000..0fc104d0fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java
new file mode 100644
index 0000000000..38bbaeebe0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory
new file mode 100644
index 0000000000..e8ee318b6c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory
new file mode 100644
index 0000000000..51ed2449fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory
new file mode 100644
index 0000000000..70b17a2f00
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory
new file mode 100644
index 0000000000..a21b75b570
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator
new file mode 100644
index 0000000000..0182f52086
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
new file mode 100644
index 0000000000..c5c7e543ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory
@@ -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.DefaultDomainRegistryFactory
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder
new file mode 100644
index 0000000000..61edf5111e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
new file mode 100644
index 0000000000..9ca8971396
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
@@ -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.assembly.impl.EndpointRegistryImpl;ranking=100,scheme=vm
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer
new file mode 100644
index 0000000000..fb951e75d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
new file mode 100644
index 0000000000..576e52d8ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler
@@ -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.work.impl.DefaultWorkScheduler
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/endpoint-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/endpoint-validation-messages.properties
new file mode 100644
index 0000000000..7be0f2b4a2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/core/src/main/resources/endpoint-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.
+#
+#
+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.
diff --git a/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java
new file mode 100644
index 0000000000..1302bed681
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java
new file mode 100644
index 0000000000..8fcead004d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java
new file mode 100644
index 0000000000..c268e133e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java
new file mode 100644
index 0000000000..16ca5fd00e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java
new file mode 100644
index 0000000000..2d791e5012
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java
new file mode 100644
index 0000000000..c0183b6f9b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java
new file mode 100644
index 0000000000..307f24aca7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java
new file mode 100644
index 0000000000..c0f35d427c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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();
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java
new file mode 100644
index 0000000000..a452d6f371
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java
new file mode 100644
index 0000000000..122609d7e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java
new file mode 100644
index 0000000000..f6435659ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java
new file mode 100644
index 0000000000..ca7bf9b3d7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest b/tags/java/sca/2.0-M4-RC2/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest
new file mode 100644
index 0000000000..ad23df3761
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/data-api/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/data-api/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/data-api/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/data-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1e48fa6477
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/data-api/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.data.collection;version="2.0.0"
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA Data API
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1254955362620
+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/tags/java/sca/2.0-M4-RC2/modules/data-api/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/data-api/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/data-api/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/tags/java/sca/2.0-M4-RC2/modules/data-api/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/data-api/pom.xml
new file mode 100644
index 0000000000..635aa029f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java
new file mode 100644
index 0000000000..f1841c975e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.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.data.collection;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Provides access to a collection of data items.
+ *
+ * @version $Rev$ $Date$
+ */
+@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/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java
new file mode 100644
index 0000000000..5903fd95a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.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.data.collection;
+
+
+/**
+ * Represents a key/data pair in a data collection.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java
new file mode 100644
index 0000000000..37042c0895
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java
new file mode 100644
index 0000000000..229b29f5cd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java
new file mode 100644
index 0000000000..69512058b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java b/tags/java/sca/2.0-M4-RC2/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java
new file mode 100644
index 0000000000..7f13db5228
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..bc9ebc0bc8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Data Binding for Axiom
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397285015
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/pom.xml
new file mode 100644
index 0000000000..34c3a7818f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</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.7</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.7</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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java
new file mode 100644
index 0000000000..a2e6abbf19
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.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.axiom;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.tuscany.sca.databinding.WrapperHandler;
+import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
+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 dataType, Operation operation) {
+ 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, dataType, operation);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java
new file mode 100644
index 0000000000..cd820ab4b4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java
new file mode 100644
index 0000000000..f44297edb7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java
new file mode 100644
index 0000000000..d2a7f861e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java
new file mode 100644
index 0000000000..947cd99a19
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java
new file mode 100644
index 0000000000..6d8d4dce99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java
new file mode 100644
index 0000000000..ea40e61746
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java
new file mode 100644
index 0000000000..b2c004324c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java
new file mode 100644
index 0000000000..01e7003b20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java
new file mode 100644
index 0000000000..9084f09dc0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java
new file mode 100644
index 0000000000..88d6b462c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java
new file mode 100644
index 0000000000..9eccd52d74
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java
new file mode 100644
index 0000000000..761185c297
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java
new file mode 100644
index 0000000000..7453cb787a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xml
new file mode 100644
index 0000000000..df901d183d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xsd b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..af1e73172d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/order.wsdl b/tags/java/sca/2.0-M4-RC2/modules/databinding-axiom/src/test/resources/order.wsdl
new file mode 100644
index 0000000000..913d9e4928
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a59109acef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF
@@ -0,0 +1,40 @@
+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
+ "
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Data Binding for JAXB-AXIOM
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397336953
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/pom.xml
new file mode 100644
index 0000000000..c1c3f74227
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.7</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.7</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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java
new file mode 100644
index 0000000000..862894be09
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java
new file mode 100644
index 0000000000..aa5fc5b789
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd
new file mode 100644
index 0000000000..241ec15d36
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..de480e1e3f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/META-INF/MANIFEST.MF
@@ -0,0 +1,55 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Data Binding for JAXB
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397221390
+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.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.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.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/pom.xml
new file mode 100644
index 0000000000..2d744bcd93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java
new file mode 100644
index 0000000000..57922e1c89
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java
new file mode 100644
index 0000000000..91cb39b0f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java
new file mode 100644
index 0000000000..35adffe23b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java
new file mode 100644
index 0000000000..062da48206
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java
new file mode 100644
index 0000000000..08ea27725d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java
new file mode 100644
index 0000000000..ba156ba548
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java
new file mode 100644
index 0000000000..a611219f21
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java
new file mode 100644
index 0000000000..61e4066ee8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.util.LRUCache;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java
new file mode 100644
index 0000000000..c68456e733
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.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.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.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.databinding.util.LRUCache;
+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) {
+ return ((JAXBElement)value).getValue();
+ } 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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java
new file mode 100644
index 0000000000..bd214cb02c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.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.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.WrapperHandler;
+import org.apache.tuscany.sca.databinding.XMLTypeHelper;
+import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
+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 dataType, Operation operation) {
+ try {
+ boolean isElement = false;
+ if (dataType == null) {
+ Class cls = arg.getClass();
+ if (arg instanceof JAXBElement) {
+ isElement = true;
+ cls = ((JAXBElement)arg).getDeclaredType();
+ }
+ dataType = new DataTypeImpl<XMLType>(NAME, cls, XMLType.UNKNOWN);
+ }
+ JAXBContext context = contextHelper.createJAXBContext(dataType);
+ arg = JAXBContextHelper.createJAXBElement(context, dataType, arg);
+ Document doc = domHelper.newDocument();
+ context.createMarshaller().marshal(arg, doc);
+ Object value = context.createUnmarshaller().unmarshal(doc, dataType.getPhysical());
+ if (isElement && value instanceof JAXBElement) {
+ return value;
+ }
+ return JAXBContextHelper.createReturnValue(context, dataType, 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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java
new file mode 100644
index 0000000000..217345caba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java
new file mode 100644
index 0000000000..84529752de
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java
new file mode 100644
index 0000000000..7473a8e56e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java
new file mode 100644
index 0000000000..a1f4c12c8f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java
new file mode 100644
index 0000000000..5f90aa4d7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java
new file mode 100644
index 0000000000..6236a336a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java
new file mode 100644
index 0000000000..2ffb565745
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java
new file mode 100644
index 0000000000..898e5b07bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java
new file mode 100644
index 0000000000..5fa98b5ed1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java
new file mode 100644
index 0000000000..d177d53eda
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java
new file mode 100644
index 0000000000..8af51f6f5c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java
new file mode 100644
index 0000000000..5c5c892f33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java
new file mode 100644
index 0000000000..7f616ac5e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.util.LRUCache;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java
new file mode 100644
index 0000000000..e612af396b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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);
+ 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);
+ 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);
+ assertTrue(copy instanceof USAddress);
+ assertEquals("San Jose", (copy).getCity());
+
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java
new file mode 100644
index 0000000000..f5cff68969
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java
new file mode 100644
index 0000000000..6e2a540ada
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java
new file mode 100644
index 0000000000..6037212e5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java
new file mode 100644
index 0000000000..9bdfb108fe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java
new file mode 100644
index 0000000000..b8e9ee7f7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java
new file mode 100644
index 0000000000..5c511e6ccb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java
new file mode 100644
index 0000000000..3c3992524a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java
new file mode 100644
index 0000000000..62dfa6f73c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
new file mode 100644
index 0000000000..98aefed546
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/resources/ipo.xsd b/tags/java/sca/2.0-M4-RC2/modules/databinding-jaxb/src/test/resources/ipo.xsd
new file mode 100755
index 0000000000..04e8cb44f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/LICENSE
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..21024b3efd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/META-INF/MANIFEST.MF
@@ -0,0 +1,33 @@
+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"
+Tool: Bnd-0.0.357
+Bundle-Name: Apache Tuscany SCA Data Binding for JSON
+Created-By: 1.6.0_15 (Apple Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1254338075268
+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.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/NOTICE
new file mode 100644
index 0000000000..fdfa0e9faa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/pom.xml
new file mode 100644
index 0000000000..1cc23c58b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</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.1</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.7</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.7</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java
new file mode 100644
index 0000000000..a9edc66ae8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java
new file mode 100644
index 0000000000..4e08384f09
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java
new file mode 100644
index 0000000000..b70f772696
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java
new file mode 100644
index 0000000000..28cadc6666
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.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.json;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.databinding.impl.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 dataType, Operation operation) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java
new file mode 100644
index 0000000000..bc6184189a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.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.json;
+
+import org.codehaus.jettison.json.JSONException;
+import org.codehaus.jettison.json.JSONObject;
+
+/**
+ * @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) {
+ try {
+ json = new JSONObject(((org.json.JSONObject)source).toString());
+ } catch (JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ return json;
+ }
+
+ /**
+ * 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 <T> T toJSON(String json, Class<T> type) {
+ if (type == JSONObject.class) {
+ try {
+ return type.cast(new JSONObject(json));
+ } catch (JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ } else {
+ if (type == null) {
+ type = (Class<T>)org.json.JSONObject.class;
+ }
+ try {
+ return type.cast(new org.json.JSONObject(json));
+ } catch (org.json.JSONException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java
new file mode 100644
index 0000000000..0d52c66e17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java
new file mode 100644
index 0000000000..866b9ff6ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java
new file mode 100644
index 0000000000..ff5968bccd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java
new file mode 100644
index 0000000000..9a719fc743
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java
new file mode 100644
index 0000000000..fb02d27b05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..800e4a43fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
@@ -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.
+
+# 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.JavaBean2JSON;source=java:complexType,target=JSON,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JavaBean2JSON;source=java:simpleType,target=JSON,weight=80000,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.JavaBean2JSON;source=java:array,target=JSON,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JavaBean2JSON;source=commonj.sdo.DataObject,target=JSON,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JavaBean2JSON;source=javax.xml.bind.JAXBElement,target=JSON,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:complexType,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:simpleType,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=commonj.sdo.DataObject,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=javax.xml.bind.JAXBElement,weight=80000,public=false
+org.apache.tuscany.sca.databinding.json.JSON2JavaBean;source=JSON,target=java:array,weight=80000,public=false
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java
new file mode 100644
index 0000000000..874378bf92
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.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.json;
+
+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 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();
+
+ XMLStreamReader reader = XMLInputFactory.newInstance().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-37
+ /*
+ JSON2XMLStreamReader t2 = new JSON2XMLStreamReader();
+ XMLStreamReader reader2 = t2.transform(json, null);
+ StringWriter sw = new StringWriter();
+ XMLStreamWriter streamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(sw);
+ new XMLStreamSerializer().serialize(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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java
new file mode 100644
index 0000000000..3b36f5be74
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java
new file mode 100644
index 0000000000..60b293c1d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java
new file mode 100644
index 0000000000..d32e0763c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java
new file mode 100644
index 0000000000..3a2b95a4e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java
new file mode 100644
index 0000000000..fd0557d0a2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/resources/ipo.xsd b/tags/java/sca/2.0-M4-RC2/modules/databinding-json/src/test/resources/ipo.xsd
new file mode 100644
index 0000000000..5a493e1746
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/databinding/LICENSE
new file mode 100644
index 0000000000..616bec99ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/databinding/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..324feab09a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/META-INF/MANIFEST.MF
@@ -0,0 +1,73 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA DataBinding Framework
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397181875
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/databinding/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/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/tags/java/sca/2.0-M4-RC2/modules/databinding/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding/pom.xml
new file mode 100644
index 0000000000..0b837dc004
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-xsd</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-common-xml</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java
new file mode 100644
index 0000000000..7c4ed35eb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.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;
+
+
+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$
+ */
+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.
+ *
+ * @param object source object to copy
+ * @param dataType The data type
+ * @param operation The operation
+ * @return copy of the object passed in as argument
+ */
+ Object copy(Object object, DataType dataType, Operation operation);
+
+ /**
+ * Get the XML type helper for Java types
+ * @return The databinding-specific XML type helper class
+ */
+ XMLTypeHelper getXMLTypeHelper();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java
new file mode 100644
index 0000000000..2ff5d866b4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.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;
+
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * An extension point for data binding extensions.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java
new file mode 100644
index 0000000000..505a810276
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java
new file mode 100644
index 0000000000..1aac6d48be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java
new file mode 100644
index 0000000000..19455fcd29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.extensibility.ServiceDiscovery;
+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;
+ }
+ 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 dataType, Operation operation) {
+ return getDataBinding().copy(object, dataType, operation);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java
new file mode 100644
index 0000000000..39889b1e97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java
new file mode 100644
index 0000000000..8184d739a8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.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.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$
+ */
+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 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 the output data
+ * @param data The orginal output
+ * @param operation The operation
+ * @return The copy
+ */
+ Object copyOutput(Object data, Operation operation);
+
+ /**
+ * Copy the fault data
+ * @param fault The orginal fault data
+ * @param operation The operation
+ * @return The copy
+ */
+ Object copyFault(Object fault, Operation operation);
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java
new file mode 100644
index 0000000000..81264923eb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java
new file mode 100644
index 0000000000..600a6477f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java
new file mode 100644
index 0000000000..ece8027c29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.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 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java
new file mode 100644
index 0000000000..9ffadd1eae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.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.util.Map;
+
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Context for data transformation
+ *
+ * @version $Rev$ $Date$
+ */
+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 the ClassLoader
+ *
+ * @return Returns the ClassLoader
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ * Get a map of metadata
+ *
+ * @return Returns a map of the metadata
+ */
+ Map<String, Object> getMetadata();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java
new file mode 100644
index 0000000000..4f949f7dff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.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;
+
+
+/**
+ * Reports problems during data transformation
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java
new file mode 100644
index 0000000000..2aa0ad7c15
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java
new file mode 100644
index 0000000000..ee7efe4860
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java
new file mode 100644
index 0000000000..ee4e35555c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.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;
+
+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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java
new file mode 100644
index 0000000000..e940f8675f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.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;
+
+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
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java
new file mode 100644
index 0000000000..4405077e29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java
new file mode 100644
index 0000000000..650e909c61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java
new file mode 100644
index 0000000000..51ca792171
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseDataBinding.java
new file mode 100644
index 0000000000..cb9f2969e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseDataBinding.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.databinding.impl;
+
+
+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 org.apache.tuscany.sca.interfacedef.util.XMLType;
+
+/**
+ * Base Implementation of DataBinding
+ *
+ * @version $Rev$ $Date$
+ */
+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 dataType, Operation operation) {
+ return object;
+ }
+
+ public XMLTypeHelper getXMLTypeHelper() {
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseTransformer.java
new file mode 100644
index 0000000000..94a2cdb0bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/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.impl;
+
+import org.apache.tuscany.sca.databinding.Transformer;
+
+/**
+ * Base Implementation of Transformer which provides the registration to the
+ * transformer registry
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java
new file mode 100644
index 0000000000..01916dfb96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.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.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;
+
+/**
+ * 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 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) {
+ 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, 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java
new file mode 100644
index 0000000000..95afd45380
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.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.impl;
+
+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.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.impl.BaseTransformer#getSourceType()
+ */
+ @Override
+ protected Class<Object> getSourceType() {
+ return Object.class;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.databinding.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java
new file mode 100644
index 0000000000..70efd6a5c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.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.impl;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java
new file mode 100644
index 0000000000..45896ca6a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.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 javax.xml.namespace.QName;
+
+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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java
new file mode 100644
index 0000000000..195c04e9c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.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.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.security.AccessController;
+import java.security.PrivilegedAction;
+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.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$
+ */
+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 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);
+ this.faultExceptionMapper =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).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());
+
+ //FIXME The ClassLoader should be passed in
+ // 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();
+ }
+ });
+
+ 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, classLoader, 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;
+ }
+
+ 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 = null;
+ for (DataType exType : targetOperation.getFaultTypes()) {
+ if (((Class)exType.getPhysical()).isInstance(result)) {
+ if (result instanceof FaultException) {
+ DataType faultType = (DataType)exType.getLogical();
+ if (((FaultException)result).isMatchingType(faultType.getLogical())) {
+ targetDataType = exType;
+ break;
+ }
+ } else {
+ targetDataType = exType;
+ break;
+ }
+ }
+ }
+
+ /*
+ if (targetDataType == null) {
+ // Not a business exception
+ return resultMsg;
+ }
+ */
+
+ 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;
+
+ }
+
+ 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, null);
+ }
+
+ /**
+ * Copy data using the specified databinding.
+ * @param data input data
+ * @param dataType
+ * @return a copy of the data
+ */
+ private Object copy(Object data, DataType dataType, Operation operation) {
+ 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(dataType.getDataBinding());
+ // If no databinding was specified, introspect the given arg to
+ // determine its databinding
+ if (dataBinding == null) {
+ if (!"java:array".equals(dataType.getDataBinding())) {
+ dataType = dataBindings.introspectType(data, operation);
+ if (dataType != null) {
+ String db = dataType.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 dataBinding.copy(data, dataType, operation);
+ } else {
+ return data;
+ }
+ }
+
+ /**
+ * 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) {
+ if (input == null) {
+ return null;
+ }
+ Object[] data = (input instanceof Object[]) ? (Object[])input : new Object[] {input};
+ List<DataType> inputTypes = operation.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));
+ map.put(arg, copiedArg);
+ copy[i] = copiedArg;
+ }
+ }
+ }
+ return copy;
+ }
+
+ public Object copyOutput(Object data, Operation operation) {
+ return copy(data, operation.getOutputType(), operation);
+ }
+
+ public Object copyFault(Object fault, Operation operation) {
+ if (faultExceptionMapper == null) {
+ return fault;
+ }
+ for (DataType et : operation.getFaultTypes()) {
+ if (et.getPhysical().isInstance(fault)) {
+ Throwable ex = (Throwable)fault;
+ DataType<DataType> exType =
+ new DataTypeImpl<DataType>(ex.getClass(), new DataTypeImpl<XMLType>(ex.getClass(), XMLType.UNKNOWN));
+ faultExceptionMapper.introspectFaultDataType(exType, operation, false);
+ DataType faultType = exType.getLogical();
+ Object faultInfo = faultExceptionMapper.getFaultInfo(ex, faultType.getPhysical(), operation);
+ faultInfo = copy(faultInfo, faultType);
+ fault =
+ faultExceptionMapper.wrapFaultInfo(exType, ex.getMessage(), faultInfo, ex.getCause(), operation);
+ return fault;
+ }
+ }
+ return fault;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java
new file mode 100644
index 0000000000..a1a89005b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java
new file mode 100644
index 0000000000..c91176fc2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.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.impl;
+
+import javax.xml.namespace.QName;
+
+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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java
new file mode 100644
index 0000000000..9ffa950f1a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java
new file mode 100644
index 0000000000..a5b8e0a0bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.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.impl;
+
+import java.lang.ref.WeakReference;
+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>();
+
+ private WeakReference<ClassLoader> classLoaderRef;
+
+ public TransformationContextImpl() {
+ super();
+ // This is used only for testing
+ setClassLoader(Thread.currentThread().getContextClassLoader());
+ }
+
+ public TransformationContextImpl(DataType sourceDataType,
+ DataType targetDataType,
+ ClassLoader classLoader,
+ Map<String, Object> metadata) {
+ super();
+ this.sourceDataType = sourceDataType;
+ this.targetDataType = targetDataType;
+ setClassLoader(classLoader);
+ if (metadata != null) {
+ this.metadata.putAll(metadata);
+ }
+ }
+
+ public TransformationContextImpl(DataType sourceDataType,
+ DataType targetDataType,
+ Map<String, Object> metadata) {
+ super();
+ this.sourceDataType = sourceDataType;
+ this.targetDataType = targetDataType;
+ setClassLoader(Thread.currentThread().getContextClassLoader());
+ 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 final void setClassLoader(ClassLoader classLoader) {
+ this.classLoaderRef = new WeakReference<ClassLoader>(classLoader);
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoaderRef.get();
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
new file mode 100644
index 0000000000..fb747864e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java
@@ -0,0 +1,945 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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$
+ */
+public class XSDDataTypeConverter {
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java
new file mode 100644
index 0000000000..fbca9b0444
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java
new file mode 100644
index 0000000000..5dc13bd60b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java
new file mode 100644
index 0000000000..f582499b70
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java
new file mode 100644
index 0000000000..4942fef0da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java
new file mode 100644
index 0000000000..b94b944a98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java
new file mode 100644
index 0000000000..4981699792
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.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.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.impl.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 dataType, Operation operation) {
+ 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 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 = 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java
new file mode 100644
index 0000000000..6886462ac8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java
new file mode 100644
index 0000000000..b8b97d4425
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.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.javabeans;
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
+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$
+ */
+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 dataType, Operation operation) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java
new file mode 100644
index 0000000000..6a30605f0f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java
new file mode 100644
index 0000000000..ae06d68e67
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java
new file mode 100644
index 0000000000..847fcf226c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/LRUCache.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/LRUCache.java
new file mode 100644
index 0000000000..34a82fd2d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/LRUCache.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.databinding.util;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * A Simple LRU Cache
+ *
+ * @version $Revision$
+ * @param <K>
+ * @param <V>
+ */
+
+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 10000
+ */
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java
new file mode 100644
index 0000000000..ed59911a0b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java
new file mode 100644
index 0000000000..ed0b5c9923
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.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.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.WrapperHandler;
+import org.apache.tuscany.sca.databinding.impl.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.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$
+ */
+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, Operation operation) {
+ if (Node.class.isAssignableFrom(source.getClass())) {
+ Node nodeSource = (Node)source;
+ return nodeSource.cloneNode(true);
+ }
+ return super.copy(source, dataType, operation);
+ }
+
+ @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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java
new file mode 100644
index 0000000000..4ce5dc6c69
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java
new file mode 100644
index 0000000000..5f583da283
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.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.xml;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.stream.StreamSource;
+
+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.impl.BaseTransformer;
+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 static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java
new file mode 100644
index 0000000000..39116ba4a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java
new file mode 100644
index 0000000000..e40c3006fb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.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.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.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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 static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java
new file mode 100644
index 0000000000..3b7bd3088a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java
new file mode 100644
index 0000000000..5500d0bcca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.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.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.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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 static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java
new file mode 100644
index 0000000000..d5bf7e76b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java
new file mode 100644
index 0000000000..3c9022bc3c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java
new file mode 100644
index 0000000000..1b54b1fd1e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.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.StringWriter;
+
+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.impl.BaseTransformer;
+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 static final Node2Writer TRANSFORMER = new Node2Writer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java
new file mode 100644
index 0000000000..c9631595dc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.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.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.databinding.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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 static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java
new file mode 100644
index 0000000000..3d89a26cab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java
new file mode 100644
index 0000000000..70387fa862
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.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.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.databinding.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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 static final Source2ResultTransformer TRANSFORMER = new Source2ResultTransformer();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java
new file mode 100644
index 0000000000..188ecaffa3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java
new file mode 100644
index 0000000000..b6b3c05462
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java
new file mode 100644
index 0000000000..0bb13bb3ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java
new file mode 100644
index 0000000000..54b281acb5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java
new file mode 100644
index 0000000000..8a2b6b39aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.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 javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+
+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.impl.BaseTransformer;
+
+/**
+ * Transform TrAX Source to Result
+ *
+ * @version $Rev$ $Date$
+ */
+public class Source2ResultTransformer extends BaseTransformer<Source, Result> implements
+ PushTransformer<Source, Result> {
+ private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java
new file mode 100644
index 0000000000..2ed548ad76
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.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 javax.xml.transform.Source;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+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.impl.BaseTransformer;
+
+/**
+ * Transform TrAX Source to String
+ *
+ * @version $Rev$ $Date$
+ */
+public class Source2StringTransformer extends BaseTransformer<Source, String> implements
+ PullTransformer<Source, String> {
+ private static final TransformerFactory FACTORY = TransformerFactory.newInstance();
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java
new file mode 100644
index 0000000000..ed57992910
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.impl.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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java
new file mode 100644
index 0000000000..f8967e35b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java
new file mode 100644
index 0000000000..548342094e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java
new file mode 100644
index 0000000000..c56dba1843
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java
new file mode 100644
index 0000000000..c2de202a9b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java
new file mode 100644
index 0000000000..ac46bfd3d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java
new file mode 100644
index 0000000000..5ab7272d58
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.DataPipe;
+import org.apache.tuscany.sca.databinding.DataPipeTransformer;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java
new file mode 100644
index 0000000000..f7c895db1e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java
new file mode 100644
index 0000000000..2ebfcf06e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.DataPipe;
+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.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java
new file mode 100644
index 0000000000..a45c563293
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PushTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java
new file mode 100644
index 0000000000..fa06303433
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PullTransformer;
+import org.apache.tuscany.sca.databinding.TransformationContext;
+import org.apache.tuscany.sca.databinding.TransformationException;
+import org.apache.tuscany.sca.databinding.impl.BaseTransformer;
+
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java
new file mode 100644
index 0000000000..22b173dce5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.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.xml;
+
+
+import org.apache.tuscany.sca.databinding.impl.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding
new file mode 100644
index 0000000000..ef8a825d68
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint
new file mode 100644
index 0000000000..4cad1181b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator
new file mode 100644
index 0000000000..c91908e630
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer
new file mode 100644
index 0000000000..9f609be7e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer
new file mode 100644
index 0000000000..6c04591a1f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper
new file mode 100644
index 0000000000..f905a9aa7b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint
new file mode 100644
index 0000000000..07762a14b8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java
new file mode 100644
index 0000000000..7d14cd9dd1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.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.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.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.BaseDataBinding;
+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();
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme
new file mode 100644
index 0000000000..562c22354c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme
new file mode 100644
index 0000000000..243ac71201
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java
new file mode 100644
index 0000000000..a337dc113c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java
new file mode 100644
index 0000000000..c5d6dbbcc1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java
new file mode 100644
index 0000000000..d48711cd64
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.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.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, 3, true);
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java
new file mode 100644
index 0000000000..a74a8e5550
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(), true);
+ registry.addTransformer(new Node2Writer(), 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java
new file mode 100644
index 0000000000..e240592adf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..95f21ff4c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java
new file mode 100644
index 0000000000..27d111374a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java
new file mode 100644
index 0000000000..682fbd4243
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.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.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.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 {
+ Node2Writer node2Writer = new Node2Writer();
+ Writer2ReaderDataPipe pipe = new Writer2ReaderDataPipe();
+ PipedTransformer<Node, Writer, Reader> transformer =
+ new PipedTransformer<Node, Writer, Reader>(node2Writer, pipe);
+ Document document = DOMHelper.getInstance(new DefaultExtensionPointRegistry()).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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java
new file mode 100644
index 0000000000..8919453731
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java
new file mode 100644
index 0000000000..516b57c851
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.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.databinding.xml;
+
+import org.apache.tuscany.sca.common.xml.dom.DOMHelper;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+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 {
+ Document document = DOMHelper.getInstance(new DefaultExtensionPointRegistry()).newDocument();
+ Element element = document.createElementNS("http://ns1", "test");
+ document.appendChild(element);
+
+ new Node2String().transform(document, null);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java
new file mode 100644
index 0000000000..a8657a5be8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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();
+ String xml = t4.transform(node, null);
+ Assert.assertTrue(xml != null && xml.indexOf("<shipDate>1999-12-05</shipDate>") != -1);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java
new file mode 100644
index 0000000000..fb9895f120
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.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.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.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 {
+ InputStream is = url.openStream();
+ InputStream2Node t1 = new InputStream2Node();
+ Node node = t1.transform(is, null);
+ is.close();
+ Writer writer = new StringWriter();
+ Node2Writer t2 = new Node2Writer();
+ t2.transform(node, writer, null);
+ String str = writer.toString();
+ StringReader reader = new StringReader(str);
+ Reader2Node t3 = new Reader2Node();
+ node = t3.transform(reader, null);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ Node2OutputStream t4 = new Node2OutputStream();
+ t4.transform(node, os, null);
+ InputSource inputSource = new InputSource(new ByteArrayInputStream(os.toByteArray()));
+ InputSource2Node t5 = new InputSource2Node();
+ 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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd
new file mode 100644
index 0000000000..92a576fb98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl
new file mode 100644
index 0000000000..f011ca9f32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml b/tags/java/sca/2.0-M4-RC2/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml
new file mode 100644
index 0000000000..0ba8ade1e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/deployment/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/deployment/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c0c86e615c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/deployment/META-INF/MANIFEST.MF
@@ -0,0 +1,49 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Deployment
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397240796
+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.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.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.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/tags/java/sca/2.0-M4-RC2/modules/deployment/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/deployment/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/deployment/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/tags/java/sca/2.0-M4-RC2/modules/deployment/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/deployment/pom.xml
new file mode 100644
index 0000000000..35d0afda1d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/deployment/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java
new file mode 100644
index 0000000000..42c7596b15
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
new file mode 100644
index 0000000000..c510d10e47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.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.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.monitor.Monitor;
+
+/**
+ * A utility that provides system functions to handle Tuscany SCA application deployment
+ */
+public interface Deployer extends LifeCycleListener {
+ /**
+ * 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
+ */
+ void 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 bindingBaseURIs
+ * @param monitor
+ * @return
+ * @throws ContributionResolveException
+ * @throws CompositeBuilderException
+ */
+ Composite build(List<Contribution> contributions, Map<QName, List<String>> bindingBaseURIs, Monitor monitor)
+ throws ContributionResolveException, CompositeBuilderException;
+
+ 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();
+
+ /**
+ * 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;
+
+ /*
+ * @see org.apache.tuscany.sca.core.LifeCycleListener#start()
+ */
+ void start();
+
+ /*
+ * @see org.apache.tuscany.sca.core.LifeCycleListener#stop()
+ */
+ void stop();
+
+ /**
+ * @return
+ */
+ boolean isSchemaValidationEnabled();
+ /**
+ * @param schemaValidationEnabled
+ */
+ void setSchemaValidationEnabled(boolean schemaValidationEnabled);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java
new file mode 100644
index 0000000000..8180ac6465
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
new file mode 100644
index 0000000000..65958a493c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
@@ -0,0 +1,545 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.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;
+
+/**
+ *
+ */
+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 MonitorFactory monitorFactory;
+
+ protected static final String DEPLOYER_IMPL_VALIDATION_MESSAGES =
+ "org.apache.tuscany.sca.deployment.impl.deployer-impl-validation-messages";
+
+ /**
+ * @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;
+ }
+ 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));
+ Monitor.error(monitor, this, DEPLOYER_IMPL_VALIDATION_MESSAGES, "UnresolvedImport", import_);
+ }
+ } // 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");
+
+ loadSystemContribution(monitorFactory.createMonitor());
+
+ inited = true;
+
+ }
+
+ protected void loadSystemContribution(Monitor monitor) {
+ DefinitionsFactory definitionsFactory = modelFactories.getFactory(DefinitionsFactory.class);
+ systemDefinitions = definitionsFactory.createDefinitions();
+
+ DefinitionsExtensionPoint definitionsExtensionPoint =
+ registry.getExtensionPoint(DefinitionsExtensionPoint.class);
+ 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);
+ }
+
+ 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);
+ return contribution;
+ }
+
+ public void attachDeploymentComposite(Contribution contribution, Composite composite, boolean appending) {
+ init();
+ // Create an artifact for the deployment composite
+ Artifact artifact = contributionFactory.createArtifact();
+ String uri = composite.getName().getLocalPart() + ".composite";
+ artifact.setURI(uri);
+
+ artifact.setLocation(uri);
+ 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);
+ }
+
+ public Composite build(List<Contribution> contributions, 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, contributionList, 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 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 <T> T 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 <T> T loadXMLElement(XMLStreamReader reader, Monitor monitor) throws ContributionReadException,
+ XMLStreamException {
+ init();
+ return (T)staxProcessor.read(reader, new ProcessorContext(monitor));
+ }
+
+ public <T> T 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer
new file mode 100644
index 0000000000..46e6eba7f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorld.java
new file mode 100644
index 0000000000..2480a5e4d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java
new file mode 100644
index 0000000000..fc81dc2167
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java
new file mode 100644
index 0000000000..cc2bf92dcf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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), 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/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..f00e00a373
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sc="http://sample/composite">
+ <deployable composite="sc:HelloWorld1" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite
new file mode 100644
index 0000000000..b4fee2c7a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/domain-node/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/domain-node/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/domain-node/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/domain-node/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..abec7ae294
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Domain Node
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397240796
+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.node.configuration;version="2.0.0",
+ org.apache.tuscany.sca.node.impl;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/tags/java/sca/2.0-M4-RC2/modules/domain-node/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/domain-node/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/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/tags/java/sca/2.0-M4-RC2/modules/domain-node/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/domain-node/pom.xml
new file mode 100644
index 0000000000..ea7d82e99c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-client-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java
new file mode 100644
index 0000000000..9a10cbd306
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.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.domain.node;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.management.ConfigAttributes;
+
+public class ConfigAttributesImpl implements ConfigAttributes {
+
+ private Map<String, String> attributes = new HashMap<String, String>();
+
+ public Map<String, String> getAttributes() {
+ return attributes;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java
new file mode 100644
index 0000000000..1259870c37
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.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.domain.node;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.management.ConfigAttributes;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+
+public class DomainNode {
+
+ public static final String DOMAIN_NAME_ATTR = "domainName";
+ public static final String DOMAIN_SCHEME_ATTR = "domainScheme";
+ public static final String DEFAULT_DOMAIN_SCHEME = "vm";
+ public static final String DEFAULT_DOMAIN_NAME = "defaultDomain";
+
+ private ConfigAttributes configAttributes = new ConfigAttributesImpl();
+ private String domainRegistryURI;
+
+ private NodeFactory nodeFactory;
+ private Map<String, Node> nodes = new HashMap<String, Node>();
+
+ public DomainNode() {
+ this(DEFAULT_DOMAIN_SCHEME + "://" + DEFAULT_DOMAIN_NAME);
+ }
+
+ public DomainNode(String configURI) {
+ this.domainRegistryURI = configURI;
+ parseConfigURI(configURI);
+ start();
+ }
+
+ public DomainNode(String configURI, String... contributionLocations) {
+ this.domainRegistryURI = configURI;
+ parseConfigURI(configURI);
+ start();
+ for (String loc : contributionLocations) {
+ addContribution(loc);
+ }
+ }
+
+ public void start() {
+ if (nodeFactory != null) {
+ throw new IllegalStateException("The node is already started");
+ }
+
+ nodeFactory = NodeFactory.getInstance(configAttributes.getAttributes().get(DOMAIN_NAME_ATTR));
+ }
+
+ public boolean isStarted() {
+ return nodeFactory != null;
+ }
+
+ public void stop() {
+ if (nodeFactory == null) {
+ throw new IllegalStateException("The node is not started");
+ }
+
+ 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.createNodeConfiguration().addContribution(uri, location)
+ .setDomainRegistryURI(domainRegistryURI).setDomainURI(configAttributes.getAttributes()
+ .get(DOMAIN_NAME_ATTR)).setURI(uri);
+ Node node = nodeFactory.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 ConfigAttributes getConfigAttributes() {
+ return configAttributes;
+ }
+
+ public String getDomainName() {
+ return configAttributes.getAttributes().get(DOMAIN_NAME_ATTR);
+ }
+
+ protected void parseConfigURI(String configURI) {
+ URI uri = URI.create(fixScheme(configURI));
+ String dn = uri.getHost();
+ if (dn == null || dn.length() < 1) {
+ dn = DEFAULT_DOMAIN_NAME;
+ }
+ configAttributes.getAttributes().put(DOMAIN_NAME_ATTR, dn);
+ String scheme = uri.getScheme();
+ if (scheme != null && scheme.length() > 0) {
+ configAttributes.getAttributes().put(DOMAIN_SCHEME_ATTR, scheme);
+ }
+
+ String query = uri.getQuery();
+ if (query != null && query.length() > 0) {
+ String[] params = query.split("&");
+ for (String param : params){
+ String name = param.split("=")[0];
+ String value = param.split("=")[1];
+ configAttributes.getAttributes().put(name, value);
+ }
+ }
+ }
+
+ /**
+ * 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
+ */
+ private 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/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java
new file mode 100644
index 0000000000..2d8d15342a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.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.domain.node;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+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 = "vm://defaultDoamin";
+
+ List<String> contributions = new ArrayList<String>();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].startsWith("vm:") || args[i].startsWith("tribes:")) {
+ 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());
+ }
+ }
+
+ DomainNode node = new DomainNode(configURI, contributions.toArray(new String[contributions.size()]));
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/itest/nodes/Helloworld.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/itest/nodes/Helloworld.java
new file mode 100644
index 0000000000..ee15dfba12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java
new file mode 100644
index 0000000000..1d31a5467f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class ConfigTestCase{
+
+ @Test
+ public void testConfig() throws Exception {
+ DomainNode domain = new DomainNode("foo://someDomain:1234?p1=x&p2=y");
+ assertEquals(4, domain.getConfigAttributes().getAttributes().size());
+ assertEquals("someDomain", domain.getDomainName());
+ assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
+ assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
+ assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
+ assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
+ }
+
+ @Test
+ public void testConfig1() throws Exception {
+ DomainNode domain = new DomainNode("foo:someDomain:1234?p1=x&p2=y");
+ assertEquals(4, domain.getConfigAttributes().getAttributes().size());
+ assertEquals("someDomain", domain.getDomainName());
+ assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
+ assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
+ assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
+ assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
+ }
+
+ @Test
+ public void testConfig2() throws Exception {
+ DomainNode domain = new DomainNode("foo:/someDomain:1234?p1=x&p2=y");
+ assertEquals(4, domain.getConfigAttributes().getAttributes().size());
+ assertEquals("someDomain", domain.getDomainName());
+ assertEquals("foo", domain.getConfigAttributes().getAttributes().get("domainScheme"));
+ assertEquals("someDomain", domain.getConfigAttributes().getAttributes().get("domainName"));
+ assertEquals("x", domain.getConfigAttributes().getAttributes().get("p1"));
+ assertEquals("y", domain.getConfigAttributes().getAttributes().get("p2"));
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
new file mode 100644
index 0000000000..20d7470a66
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.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.domain.node;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import itest.nodes.Helloworld;
+import static org.junit.Assert.fail;
+
+import org.apache.tuscany.sca.domain.node.DomainNode;
+import org.junit.After;
+import org.junit.Test;
+import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.client.SCAClient;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class MultipleNodesPerJVMTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ if (clientNode != null && clientNode.isStarted()) {
+ clientNode.stop();
+ }
+ if (serviceNode != null && serviceNode.isStarted()) {
+ serviceNode.stop();
+ }
+ }
+
+ @Test
+ public void testTwoNodesDifferentDomains() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ clientNode = new DomainNode("vm://barDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+ Helloworld client = SCAClient.getService(Helloworld.class, "barDomain/HelloworldClient");
+ assertNotNull(client);
+
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (SCARuntimeException 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.isStarted()) {
+ clientNode.stop();
+ }
+ if (serviceNode != null && serviceNode.isStarted()) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java
new file mode 100644
index 0000000000..a5c829b87f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.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.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.apache.tuscany.sca.domain.node.DomainNode;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClient;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+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 = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+ }
+
+ @Test
+ public void testClient() throws Exception {
+ Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @Test
+ public void testRemovingServiceContribution() throws Exception {
+ domain.removeContribution(serviceContributionUri);
+ try {
+ SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldService");
+ // FIXME: should this be NoSuchServiceException or ServiceNotFoundException?
+ } catch (NoSuchServiceException e) {
+ // expected
+ }
+
+ Helloworld client = SCAClient.getService(Helloworld.class, "defaultDomain/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 {
+ SCAClient.getService(Helloworld.class, "defaultDomain/HelloworldClient");
+ fail();
+ } catch (NoSuchDomainException e) {
+ // expected
+ }
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (domain != null && domain.isStarted()) {
+ domain.stop();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java
new file mode 100644
index 0000000000..3ee89b0a04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.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.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.Test;
+import org.oasisopen.sca.client.SCAClient;
+
+/**
+ * This shows how to test the Calculator service component.
+ */
+public class StopStartNodesTestCase{
+
+ private static DomainNode clientNode;
+ private static DomainNode serviceNode;
+
+ @Test
+ public void testTwoNodesSameDomain() throws Exception {
+ serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ clientNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar");
+
+ Helloworld service = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldService");
+ assertNotNull(service);
+ assertEquals("Hello Petra", service.sayHello("Petra"));
+
+ Helloworld client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+
+ serviceNode.stop();
+
+ client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ assertNotNull(client);
+ try {
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ fail();
+ } catch (Exception e) {
+ // expected
+ }
+
+ serviceNode = new DomainNode("vm://fooDomain", "target/test-classes/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar");
+ client = SCAClient.getService(Helloworld.class, "fooDomain/HelloworldClient");
+ assertNotNull(client);
+ assertEquals("Hi Hello Petra", client.sayHello("Petra"));
+ }
+
+ @After
+ public void tearDownAfterClass() throws Exception {
+ if (clientNode != null && clientNode.isStarted()) {
+ clientNode.stop();
+ }
+ if (serviceNode != null && serviceNode.isStarted()) {
+ serviceNode.stop();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..3e9ae79a41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
new file mode 100644
index 0000000000..40333cab75
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..82533cda1b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/META-INF/MANIFEST.MF
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.xsd.impl;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Tomcat Tribes Based EndPoint Registry
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397174343
+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.dht
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
+Import-Package: 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.policy;version="2.0.0",
+ org.apache.tuscany.sca.runtime;version="2.0.0"
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/README b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/README
new file mode 100644
index 0000000000..502776b568
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/README
@@ -0,0 +1 @@
+This is still a bit working in progress, if you want move to contrib. Not include in a distribution release.
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/TODO b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/TODO
new file mode 100644
index 0000000000..3f239cf3c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/TODO
@@ -0,0 +1,3 @@
+* Update and notify infrastucture on what happens.
+* a clear test case with multiple hosts.
+* Fix dependencies ..a better pom
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/pom.xml
new file mode 100644
index 0000000000..2f683a1797
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-endpoint-dht</artifactId>
+ <name>Apache Tuscany SCA OverlayWeaver DHT Based EndPoint Registry</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>ow</groupId>
+ <artifactId>overlayweaver</artifactId>
+ <version>0.9.5</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/java/org/apache/tuscany/sca/endpoint/dht/OverlayEndpointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/java/org/apache/tuscany/sca/endpoint/dht/OverlayEndpointRegistry.java
new file mode 100644
index 0000000000..04b260de0f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/java/org/apache/tuscany/sca/endpoint/dht/OverlayEndpointRegistry.java
@@ -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.
+ */
+
+package org.apache.tuscany.sca.endpoint.dht;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import ow.id.ID;
+import ow.routing.RoutingException;
+import ow.dht.DHT;
+import ow.dht.DHTConfiguration;
+import ow.dht.DHTFactory;
+import ow.dht.ValueInfo;
+import java.io.IOException;
+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;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * A EndpointRegistry based on Overlay Weaver DHT
+ */
+public class OverlayEndpointRegistry implements EndpointRegistry, LifeCycleListener {
+ private final static Logger logger = Logger.getLogger(OverlayEndpointRegistry.class.getName());
+ private final static int DEFAULT_PORT = 3997;
+ private final static int DEFAULT_TTL = 600 * 1000;
+ private final static String DEFAULT_DOMAIN_URI = "http://tuscany.apache.org/sca/1.1/domains/default";
+ private String domainURI = DEFAULT_DOMAIN_URI;
+ private List<EndpointReference> endpointreferences = new CopyOnWriteArrayList<EndpointReference>();
+ private List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
+ private DHT<Endpoint> map = null;
+ private ConcurrentHashMap<String, Endpoint> publishedEndpoints = new ConcurrentHashMap<String,Endpoint>();
+ private ExtensionPointRegistry registry;
+ private String joinPort= null;
+ private String address = null;
+ private int port;
+
+ public OverlayEndpointRegistry(ExtensionPointRegistry registry, Map<String, String> attributes) {
+ this.registry = registry;
+ String portStr = attributes.get("port");
+ if (portStr != null) {
+ port = DEFAULT_PORT;
+ }
+ /* This is the address that you need for join a DHT */
+ address = attributes.get("address");
+ if (address == null) {
+ address = getBindAddress();
+ }
+ }
+
+ public OverlayEndpointRegistry(String domainURI) {
+ this.domainURI = domainURI;
+ // start();
+ }
+
+ public void start() {
+ if (map != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+ /* here you have to join the DHT */
+ DHTConfiguration config = DHTFactory.getDefaultConfiguration();
+ /* the DHT behaviour should be configurable */
+ config.setRoutingStyle("Iterative");
+ config.setRoutingAlgorithm("Pastry");
+ config.setSelfPort(DEFAULT_PORT);
+ try {
+ map = DHTFactory.<Endpoint>getDHT(config);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ try {
+ map.joinOverlay(address, Integer.parseInt(joinPort));
+ }
+ catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ }
+
+ public void stop() {
+ if (map != null) {
+ map.stop();
+ map = null;
+ }
+ }
+
+ public void addEndpoint(Endpoint endpoint) {
+ int idSize = map.getRoutingAlgorithmConfiguration().getIDSizeInByte();
+ ID key = ID.getHashcodeBasedID(endpoint.getURI(), idSize);
+ try {
+ map.put(key, endpoint);
+
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ publishedEndpoints.put(endpoint.getURI(), endpoint);
+ logger.info("Add endpoint - " + endpoint);
+ }
+
+ public void addEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.add(endpointReference);
+ logger.info("Add endpoint reference - " + endpointReference);
+ }
+
+ public void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Parse the component/service/binding URI into an array of parts (componentURI, serviceName, bindingName)
+ * @param uri
+ * @return
+ */
+ private String[] parse(String uri) {
+ String[] names = new String[3];
+ int index = uri.lastIndexOf('#');
+ if (index == -1) {
+ names[0] = uri;
+ } else {
+ names[0] = uri.substring(0, index);
+ String str = uri.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: " + uri);
+ }
+ names[1] = parts[0];
+ names[2] = parts[1];
+ } else if (str.startsWith("service(") && str.endsWith(")")) {
+ str = str.substring("service(".length(), str.length() - 1);
+ names[1] = str;
+ } else {
+ throw new IllegalArgumentException("Invalid component/service/binding URI: " + uri);
+ }
+ }
+ return names;
+ }
+
+ private boolean matches(String target, String uri) {
+ String[] parts1 = parse(target);
+ String[] parts2 = parse(uri);
+ for (int i = 0; i < parts1.length; i++) {
+ if (parts1[i] == null || parts1[i].equals(parts2[i])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+
+ logger.info("Find endpoint for reference - " + endpointReference);
+
+ if (endpointReference.getReference() != null) {
+ Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
+ int idSize = map.getRoutingAlgorithmConfiguration().getIDSizeInByte();
+ ID key = ID.getHashcodeBasedID(targetEndpoint.getURI(), idSize);
+ try {
+ Set<ValueInfo<Endpoint>> values = map.get(key);
+ for (ValueInfo<Endpoint>v : values)
+ {
+ Endpoint endpoint = v.getValue();
+ if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+
+ if (!isLocal(endpoint)) {
+ endpoint.setRemote(true);
+ }
+
+ endpoint.setExtensionPointRegistry(registry);
+
+ foundEndpoints.add(endpoint);
+ logger.info("Found endpoint with matching service - " + endpoint);
+ }
+
+ }
+
+
+ } catch (Exception e)
+ {
+ throw new IllegalStateException("Routing exception during resolving endpoint");
+ }
+ }
+
+ return foundEndpoints;
+ }
+
+ private boolean isLocal(Endpoint entry) {
+ Endpoint local;
+ local = publishedEndpoints.get(entry.getURI());
+ if (local != null)
+ return true;
+ return false;
+ }
+
+ public List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ return endpointreferences;
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ /* if is local there no need to go on the net*/
+ Endpoint local = null;
+ local = publishedEndpoints.get(uri);
+ if (local != null)
+ return local;
+ /* otherwise we should check on the net */
+ int idSize = map.getRoutingAlgorithmConfiguration().getIDSizeInByte();
+ ID key = ID.getHashcodeBasedID(uri, idSize);
+ try {
+ Set<ValueInfo<Endpoint>> values = map.get(key);
+ for(ValueInfo <Endpoint> v: values)
+ {
+ return v.getValue();
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException("Routing exception during resolving endpoint");
+ }
+ return local;
+ }
+
+ public List<EndpointReference> getEndpointRefereneces() {
+ return endpointreferences;
+ }
+
+ public List<Endpoint> getEndpoints() {
+ /*TODO*/
+ return null;
+ }
+
+ public List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ /*TODO*/
+ publishedEndpoints.remove(endpoint.getURI());
+ logger.info("Remove endpoint - " + endpoint);
+ }
+
+ public void removeEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.remove(endpointReference);
+ logger.info("Remove endpoint reference - " + endpointReference);
+ }
+
+ public void removeListener(EndpointListener listener) {
+ listeners.remove(listener);
+ }
+
+ public void updateEndpoint(String uri, Endpoint endpoint) {
+ /* TODO*/
+ }
+
+ public void entryAdded(Object key, Object value) {
+ /* TODO*/
+ }
+
+ public void entryRemoved(Object key, Object value) {
+ /* TODO*/
+ }
+
+ public void entryUpdated(Object key, Object oldValue, Object newValue) {
+ /* TODO*/
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
new file mode 100644
index 0000000000..0836d07fd1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-dht/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
@@ -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.endpoint.tribes.ReplicatedEndpointRegistry;ranking=150,address=planetlab2.fem.tu-ilmenau.de,port=3998,timeout=50
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..83df715831
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.xsd.impl;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Tomcat Tribes Based EndPoint Registry
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397174343
+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.util,
+ org.apache.juli.logging;resolution:=optional,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.assembly.impl;version="2.0.0";scope=internal;resolution:=optional,
+ org.apache.tuscany.sca.core;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.runtime;version="2.0.0"
+Export-Package: org.apache.tuscany.sca.endpoint.tribes;version="2.0.0"
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/pom.xml
new file mode 100644
index 0000000000..0887885790
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/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-M4</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.18</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java
new file mode 100644
index 0000000000..98c6739854
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.getBackupNodes());
+ 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.getBackupNodes());
+ 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.getBackupNodes());
+ 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, Member[] backupNodes) 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(), entry.getBackupNodes());
+ } 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.getBackupNodes());
+ 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/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java
new file mode 100644
index 0000000000..9e540743bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
new file mode 100644
index 0000000000..ac2933564e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
@@ -0,0 +1,453 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.UUID;
+import java.util.concurrent.CopyOnWriteArrayList;
+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.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.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;
+import org.apache.tuscany.sca.endpoint.tribes.AbstractReplicatedMap.MapEntry;
+import org.apache.tuscany.sca.endpoint.tribes.MapStore.MapListener;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+
+/**
+ * A replicated EndpointRegistry based on Apache Tomcat Tribes
+ */
+public class ReplicatedEndpointRegistry 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 int port = MULTICAST_PORT;
+ private String address = MULTICAST_ADDRESS;
+ private String bind = null;
+ private int timeout = 50;
+
+ private final static String DEFAULT_DOMAIN_URI = "http://tuscany.apache.org/sca/1.1/domains/default";
+ private String domainURI = DEFAULT_DOMAIN_URI;
+ private List<EndpointReference> endpointreferences = new CopyOnWriteArrayList<EndpointReference>();
+ private List<EndpointListener> listeners = new CopyOnWriteArrayList<EndpointListener>();
+
+ private ExtensionPointRegistry registry;
+ private ReplicatedMap map;
+ private static List<URI> staticRoutes;
+
+ private String id;
+
+ private static final Channel 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) {
+ this.registry = registry;
+ this.domainURI = domainURI;
+ this.id = "[" + System.identityHashCode(this) + "]";
+ 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()));
+ }
+ 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 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()));
+ }
+ }
+ }
+
+ public void start() {
+ if (map != null) {
+ throw new IllegalStateException("The registry has already been started");
+ }
+ map =
+ new ReplicatedMap(null, createChannel(address, port, bind), timeout, this.domainURI,
+ new ClassLoader[] {ReplicatedEndpointRegistry.class.getClassLoader()});
+ map.addListener(this);
+
+ if (staticRoutes != null) {
+ StaticMembershipInterceptor smi = new StaticMembershipInterceptor();
+ for (URI staticRoute : staticRoutes) {
+ Member member;
+ try {
+ 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 void addEndpointReference(EndpointReference endpointReference) {
+ endpointreferences.add(endpointReference);
+ logger.fine("Add endpoint reference - " + endpointReference);
+ }
+
+ public void addListener(EndpointListener listener) {
+ listeners.add(listener);
+ }
+
+ /**
+ * Parse the component/service/binding URI into an array of parts (componentURI, serviceName, bindingName)
+ * @param uri
+ * @return
+ */
+ private String[] parse(String uri) {
+ String[] names = new String[3];
+ int index = uri.lastIndexOf('#');
+ if (index == -1) {
+ names[0] = uri;
+ } else {
+ names[0] = uri.substring(0, index);
+ String str = uri.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: " + uri);
+ }
+ names[1] = parts[0];
+ names[2] = parts[1];
+ } else if (str.startsWith("service(") && str.endsWith(")")) {
+ str = str.substring("service(".length(), str.length() - 1);
+ names[1] = str;
+ } else {
+ throw new IllegalArgumentException("Invalid component/service/binding URI: " + uri);
+ }
+ }
+ return names;
+ }
+
+ private boolean matches(String target, String uri) {
+ String[] parts1 = parse(target);
+ String[] parts2 = parse(uri);
+ for (int i = 0; i < parts1.length; i++) {
+ if (parts1[i] == null || parts1[i].equals(parts2[i])) {
+ continue;
+ } else {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public List<Endpoint> findEndpoint(EndpointReference endpointReference) {
+ List<Endpoint> foundEndpoints = new ArrayList<Endpoint>();
+
+ logger.fine("Find endpoint for reference - " + endpointReference);
+
+ if (endpointReference.getReference() != null) {
+ Endpoint targetEndpoint = endpointReference.getTargetEndpoint();
+ for (Object v : map.values()) {
+ Endpoint endpoint = (Endpoint)v;
+ // TODO: implement more complete matching
+ logger.fine("Matching against - " + endpoint);
+ if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ if (!isLocal(entry)) {
+ endpoint.setRemote(true);
+ }
+ // if (!entry.isPrimary()) {
+ endpoint.setExtensionPointRegistry(registry);
+ // }
+ foundEndpoints.add(endpoint);
+ logger.fine("Found endpoint with matching service - " + endpoint);
+ }
+ // else the service name doesn't match
+ }
+ }
+ return foundEndpoints;
+ }
+
+ private boolean isLocal(MapEntry entry) {
+ return entry.getPrimary().equals(map.getChannel().getLocalMember(false));
+ }
+
+ public List<EndpointReference> findEndpointReference(Endpoint endpoint) {
+ return endpointreferences;
+ }
+
+ public Endpoint getEndpoint(String uri) {
+ return (Endpoint)map.get(uri);
+ }
+
+ public List<EndpointReference> getEndpointRefereneces() {
+ return endpointreferences;
+ }
+
+ public List<Endpoint> getEndpoints() {
+ return new ArrayList(map.values());
+ }
+
+ public List<EndpointListener> getListeners() {
+ return listeners;
+ }
+
+ public void removeEndpoint(Endpoint endpoint) {
+ map.remove(endpoint.getURI());
+ logger.info("Remove 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 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());
+ newEp.setRemote(true);
+ }
+ newEp.setExtensionPointRegistry(registry);
+ for (EndpointListener listener : listeners) {
+ listener.endpointAdded(newEp);
+ }
+ }
+
+ public void entryRemoved(Object key, Object value) {
+ MapEntry entry = (MapEntry)value;
+ if (!isLocal(entry)) {
+ logger.info(id + " Remote endpoint removed: " + entry.getValue());
+ }
+ Endpoint oldEp = (Endpoint)entry.getValue();
+ for (EndpointListener listener : listeners) {
+ listener.endpointRemoved(oldEp);
+ }
+ }
+
+ 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();
+ for (EndpointListener listener : listeners) {
+ listener.endpointUpdated(oldEp, newEp);
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ //create a channel
+ GroupChannel channel = new GroupChannel();
+ McastService mcastService = (McastService)channel.getMembershipService();
+ mcastService.setPort(MULTICAST_PORT);
+ mcastService.setAddress(MULTICAST_ADDRESS);
+
+ InetAddress localhost = InetAddress.getLocalHost();
+
+ // 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
+
+ // You can use "route add 228.0.0.0 mask 252.0.0.0 192.168.1.100"
+ mcastService.setBind(getBindAddress());
+ channel.start(Channel.DEFAULT);
+ ReplicatedMap map = new ReplicatedMap(null, channel, 50, "01", null);
+ map.put(UUID.randomUUID().toString(), localhost.getHostAddress());
+ for (int i = 0; i < 4; i++) {
+ Thread.sleep(3000);
+ System.out.println(localhost + ": " + map.keySet());
+ }
+ for (Object e : map.entrySetFull()) {
+ Map.Entry en = (Map.Entry)e;
+ AbstractReplicatedMap.MapEntry entry = (AbstractReplicatedMap.MapEntry)en.getValue();
+ System.out.println(entry);
+ }
+ map.breakdown();
+ channel.stop(Channel.DEFAULT);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java
new file mode 100644
index 0000000000..762407604d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.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.endpoint.tribes;
+
+import java.io.Serializable;
+
+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, Member[] backupNodes) throws ChannelException {
+ if (!(key instanceof Serializable && value instanceof Serializable))
+ return new Member[0];
+ //select a backup node
+ Member[] backup = getMapMembers();
+
+ if (backup == null || backup.length == 0)
+ return null;
+
+ // Set the receivers to these members that are not in the backup nodes yet
+ Member[] members = backup;
+ if (backupNodes != null) {
+ members = getMapMembersExcl(backupNodes);
+ }
+
+ //publish the data out to all nodes
+ MapMessage msg =
+ new MapMessage(getMapContextName(), MapMessage.MSG_COPY, false, (Serializable)key, (Serializable)value,
+ null, channel.getLocalMember(false), backup);
+
+ getChannel().send(members, msg, getChannelSendOptions());
+
+ return backup;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
new file mode 100644
index 0000000000..a16785beef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry
@@ -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.ReplicatedEndpointRegistry;ranking=150,address=228.0.0.100,port=50000,timeout=50,scheme=tribes
diff --git a/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
new file mode 100644
index 0000000000..a574ba9328
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.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.endpoint.tribes;
+
+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.junit.Assert;
+import org.junit.Ignore;
+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);
+
+ ReplicatedEndpointRegistry ep1 = new ReplicatedEndpointRegistry(extensionPoints, null, "foo", "bar");
+ System.out.println("ep1 is: " + ep1);
+ ep1.start();
+
+ Endpoint e1 = assemblyFactory.createEndpoint();
+ e1.setURI("e1uri");
+ e1.setExtensionPointRegistry(extensionPoints);
+ ep1.addEndpoint(e1);
+
+ Endpoint e1p = ep1.getEndpoint("e1uri");
+ System.out.println("EP1 in Registry 1: " + e1p);
+ Assert.assertNotNull(e1p);
+
+ ReplicatedEndpointRegistry ep2 = new ReplicatedEndpointRegistry(extensionPoints, null, "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, null, "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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..3a43caa6e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.extensibility.equinox;version=
+ "2.0.0"
+Bundle-ActivationPolicy: lazy
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Extensibility for Eclipse Equinox
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: true
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397425625
+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
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/NOTICE
new file mode 100644
index 0000000000..db5ab284d5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/NOTICE
@@ -0,0 +1,5 @@
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/pom.xml
new file mode 100644
index 0000000000..19a61006cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java
new file mode 100644
index 0000000000..2b3e087e52
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.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.extensibility.equinox;
+
+import static org.apache.tuscany.sca.extensibility.ServiceDeclarationParser.parseDeclaration;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+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.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+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.ServiceDiscoverer;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+
+/**
+ * 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;
+
+ public EquinoxServiceDiscoverer(BundleContext context) {
+ this.context = context;
+ }
+
+ 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();
+ }
+ }
+
+ 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);
+ serviceName = "META-INF/services/" + serviceName;
+
+ Set<URL> visited = new HashSet<URL>();
+ for (Bundle bundle : context.getBundles()) {
+ if (bundle.getBundleId() == 0 || bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null) {
+ // Skip system bundle as it has access to the application classloader
+ // Skip bundle fragments too
+ 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 {
+ // 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 {
+ 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 ("".equals(value)) {
+ value = key;
+ key = "";
+ }
+ if (!"".equals(key)) {
+ attributes.put(key, value);
+ attributes.put("uri", key);
+ }
+ attributes.putAll(parseDeclaration(value));
+ ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(bundle, url, value, attributes);
+ descriptors.add(descriptor);
+ }
+ continue;
+ }
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ int count = 0;
+ while (true) {
+ String line = reader.readLine();
+ if (line == null)
+ break;
+ line = line.trim();
+ if (!line.startsWith("#") && !"".equals(line)) {
+ String reg = line.trim();
+ if (debug) {
+ logger.fine("Registering service provider: " + reg);
+ }
+
+ Map<String, String> attributes = parseDeclaration(reg);
+ String className = attributes.get("class");
+ if (className == null) {
+ // Add a unique class name to prevent equals() from returning true
+ className = "_class_" + count;
+ count++;
+ }
+ ServiceDeclarationImpl descriptor =
+ new ServiceDeclarationImpl(bundle, url, className, attributes);
+ descriptors.add(descriptor);
+ }
+ }
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ } 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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java
new file mode 100644
index 0000000000..4ccaf57c19
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.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.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());
+
+ public void start(BundleContext context) throws Exception {
+ EquinoxServiceDiscoverer 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);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
new file mode 100644
index 0000000000..4b5fffff01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java
new file mode 100644
index 0000000000..aa9cd50abc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java
new file mode 100644
index 0000000000..deb4221f4f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.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.extensibility.equinox;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
+
+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 testBundle;
+ 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.jar");
+ testBundle = context.installBundle("test-bundle", is);
+ is.close();
+ discoverer = new EquinoxServiceDiscoverer(context);
+ File dep = new File("target/bundles");
+ List<Bundle> bundles = new ArrayList<Bundle>();
+ if(dep.isDirectory()) {
+ for (File f : dep.listFiles()) {
+ BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
+ JarInputStream jis = new JarInputStream(bis);
+ Manifest manifest = jis.getManifest();
+ if (manifest == null || manifest.getMainAttributes().getValue("Bundle-Name") == null) {
+ bis.close();
+ continue;
+ }
+ bis.close();
+ bis = new BufferedInputStream(new FileInputStream(f));
+ Bundle b = context.installBundle(f.getName(), bis);
+ System.out.println("Installed " + b.getSymbolicName() + " [" + getState(b) + "]");
+ bundles.add(b);
+ bis.close();
+ }
+ }
+ for (Bundle b : bundles) {
+ b.start();
+ System.out.println("Started "+b.getSymbolicName() + " [" + getState(b) + "]");
+ /*
+ // Get the Platform.getExtensionRegistry()
+ if ("org.eclipse.core.runtime".equals(b.getSymbolicName())) {
+ // The Platform class loaded by the bundle is different that the one
+ // on the classpath
+ Class<?> cls = b.loadClass("org.eclipse.core.runtime.Platform");
+ Method m = cls.getMethod("getExtensionRegistry");
+ Object reg = m.invoke(cls);
+ System.out.println(reg);
+ }
+ */
+ }
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (testBundle != null) {
+ // Uninstall the bundle to clean up the cache
+ testBundle.uninstall();
+ }
+ host.stop();
+ System.out.println("Done");
+ }
+
+ @Test
+ public void testDiscovery() throws IOException {
+ Collection<ServiceDeclaration> descriptors = discoverer.getServiceDeclarations("test.TestService");
+ Assert.assertEquals(1, 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);
+ }
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java
new file mode 100644
index 0000000000..566cd6e1a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/resources/test-bundle.jar b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/resources/test-bundle.jar
new file mode 100644
index 0000000000..afee051f61
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility-equinox/src/test/resources/test-bundle.jar
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/extensibility/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/extensibility/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..147f17e4a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Extensibility
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397079296
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/extensibility/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/extensibility/pom.xml
new file mode 100644
index 0000000000..85bf9b4057
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-extensibility</artifactId>
+ <name>Apache Tuscany SCA Extensibility</name>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
new file mode 100644
index 0000000000..3ffe893553
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.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.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.
+ *
+ * @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();
+ }
+
+ protected 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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
new file mode 100644
index 0000000000..2ccb192fdb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.HashMap;
+import java.util.Map;
+
+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 HashMap<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 synchronized 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 synchronized 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 synchronized <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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
new file mode 100644
index 0000000000..fc958afad5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.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.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;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
new file mode 100644
index 0000000000..41e2377db5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 synchronized void addUtility(Object utility) {
+ addUtility(null, utility);
+ }
+
+ public synchronized 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 synchronized <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 synchronized 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 synchronized <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 synchronized 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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java
new file mode 100644
index 0000000000..762fcad7aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java
new file mode 100644
index 0000000000..4d38cb8afe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.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;
+
+/**
+ * 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java
new file mode 100644
index 0000000000..7a461a5773
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.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;
+
+/**
+ * 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
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
new file mode 100644
index 0000000000..f05c11f9b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.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;
+
+
+/**
+ * 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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java
new file mode 100644
index 0000000000..7070d33f2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java
new file mode 100644
index 0000000000..bfeeac5696
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.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.core;
+
+
+/**
+ * The extension point for the Tuscany core utility extensions.
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.java
new file mode 100644
index 0000000000..e6ccb22ed5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ClassLoaderContext.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.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
+ */
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java
new file mode 100644
index 0000000000..08b2ac2c3f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.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.extensibility;
+
+import static org.apache.tuscany.sca.extensibility.ServiceDeclarationParser.parseDeclaration;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.ref.WeakReference;
+import java.net.URL;
+import java.net.URLConnection;
+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.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+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 ClassLoader getContextClassLoader() {
+ return classLoaderReference.get();
+ }
+
+ private List<URL> getResources(final String name) throws IOException {
+ try {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<List<URL>>() {
+ public List<URL> run() throws IOException {
+ List<URL> urls = Collections.list(classLoaderReference.get().getResources(name));
+ return 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());
+ }
+
+ // 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));
+ ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(url, value, attributes);
+ descriptors.add(descriptor);
+ }
+ continue;
+ }
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new InputStreamReader(is));
+ int count = 0;
+ while (true) {
+ String line = reader.readLine();
+ if (line == null)
+ break;
+ line = line.trim();
+ if (!line.startsWith("#") && !"".equals(line)) {
+ String reg = line.trim();
+ if (debug) {
+ logger.fine("Registering service provider: " + reg);
+ }
+
+ Map<String, String> attributes = parseDeclaration(reg);
+ String className = attributes.get("class");
+ if (className == null) {
+ // Add a unique class name to prevent equals() from returning true
+ className = "_class_" + count;
+ count++;
+ }
+ ServiceDeclarationImpl descriptor = new ServiceDeclarationImpl(url, className, attributes);
+ descriptors.add(descriptor);
+ }
+ }
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Ignore
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ return descriptors;
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java
new file mode 100644
index 0000000000..209a30b08e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java
new file mode 100644
index 0000000000..993f6c6338
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.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.extensibility;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java
new file mode 100644
index 0000000000..aebd6cd3de
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java
new file mode 100644
index 0000000000..b5f26c7a34
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.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.extensibility;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.extensibility.impl.ClassLoaderDelegate;
+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.
+ *
+ *
+ * @version $Rev$ $Date$
+ */
+public final class ServiceDiscovery implements ServiceDiscoverer {
+ private final static Logger logger = Logger.getLogger(ServiceDiscovery.class.getName());
+ private final static ServiceDiscovery INSTANCE = new ServiceDiscovery();
+
+ 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();
+ 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);
+ 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();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
new file mode 100644
index 0000000000..975a7692ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.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.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
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/ClassLoaderDelegate.java
new file mode 100644
index 0000000000..d052d6b10f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java
new file mode 100644
index 0000000000..77f6f3e8db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java
new file mode 100644
index 0000000000..a998ea8506
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java
@@ -0,0 +1,1357 @@
+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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint
new file mode 100644
index 0000000000..be22b6fb13
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint
new file mode 100644
index 0000000000..4e5a05d522
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint
new file mode 100644
index 0000000000..52d7cb59b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java
new file mode 100644
index 0000000000..c0aac21596
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java
new file mode 100644
index 0000000000..9758cba3b4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java
new file mode 100644
index 0000000000..0a5f4d6442
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java
new file mode 100644
index 0000000000..7a2f680d16
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.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.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
+ 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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java
new file mode 100644
index 0000000000..7920fdf4f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java
new file mode 100644
index 0000000000..f1ed50c5f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java
new file mode 100644
index 0000000000..6a1ba4d7ba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java
new file mode 100644
index 0000000000..4def8a5227
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java b/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java
new file mode 100644
index 0000000000..2f0c34df7d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-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/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..efe05b13da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.osgi;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Jetty 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: 1225397258562
+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,
+ 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.osgi.framework;version="1.4.0",
+ org.osgi.service.http;version="1.2",
+ org.osgi.util.tracker;version="1.3.0"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.http.osgi
+Bundle-DocURL: http://www.apache.org/
+Bundle-ActivationPolicy: lazy
+Bundle-Activator: org.apache.tuscany.sca.http.osgi.OSGiServletHost
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/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/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/pom.xml
new file mode 100644
index 0000000000..b64eef7711
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-http-osgi</artifactId>
+ <name>Apache Tuscany SCA OSGi HTTP Service Based Servlet Host Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</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>org.eclipse.equinox</groupId>
+ <artifactId>http</artifactId>
+ <version>1.0.300-v20090520-1800</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/HttpServiceWrapper.java b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/HttpServiceWrapper.java
new file mode 100644
index 0000000000..3cfca3e6c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/HttpServiceWrapper.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.http.osgi;
+
+import javax.servlet.Servlet;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.HttpService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A whiteboard for HttpService and Servlet
+ */
+public class HttpServiceWrapper {
+
+ static final String SERVLET_URI = "servlet.uri";
+ private ServiceTracker httpTracker;
+ private BundleContext bc;
+
+ private class HttpServiceTracker extends ServiceTracker {
+ private HttpServiceTracker() {
+ super(bc, HttpService.class.getName(), null);
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference) {
+ HttpService httpService = (HttpService)super.addingService(reference);
+ // Register existing servlets
+ String filter = "(objectclass=" + Servlet.class.getName() + ")";
+ ServiceReference[] servlets = null;
+ try {
+ servlets = bc.getServiceReferences(null, filter);
+ } catch (InvalidSyntaxException e) {
+ throw new IllegalStateException(e);
+ }
+ for (int i = 0; servlets != null && i < servlets.length; i++) {
+ Servlet servlet = (Servlet)bc.getService(servlets[i]);
+ String alias = (String)servlets[i].getProperty(SERVLET_URI);
+
+ try {
+ httpService.registerServlet(alias, servlet, null, null);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return httpService;
+ }
+ }
+
+ public HttpServiceWrapper(BundleContext bc) {
+ super();
+ this.bc = bc;
+ }
+
+ void open() {
+ httpTracker = new HttpServiceTracker();
+ httpTracker.open();
+
+ ServiceListener sl = new ServiceListener() {
+ public void serviceChanged(ServiceEvent ev) {
+ ServiceReference sr = ev.getServiceReference();
+ switch (ev.getType()) {
+ case ServiceEvent.REGISTERED: {
+ registerServlet(sr);
+ }
+ break;
+ case ServiceEvent.UNREGISTERING: {
+ unregisterServlet(sr);
+ }
+ break;
+ }
+ }
+ };
+
+ String filter = "(objectclass=" + Servlet.class.getName() + ")";
+ try {
+ bc.addServiceListener(sl, filter);
+ ServiceReference[] servlets = bc.getServiceReferences(null, filter);
+ for (int i = 0; servlets != null && i < servlets.length; i++) {
+ sl.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, servlets[i]));
+ }
+ } catch (InvalidSyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+
+ void close() {
+ if (httpTracker != null) {
+ httpTracker.close();
+ }
+ }
+
+ void registerServlet(ServiceReference sr) {
+ Servlet servlet = (Servlet)bc.getService(sr);
+ String alias = (String)sr.getProperty(SERVLET_URI);
+
+ Object[] httpServices = httpTracker.getServices();
+
+ for (int i = 0; httpServices != null && i < httpServices.length; i++) {
+ HttpService http = (HttpService)httpServices[i];
+ try {
+ http.registerServlet(alias, servlet, null, null);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ void unregisterServlet(ServiceReference sr) {
+ String alias = (String)sr.getProperty(SERVLET_URI);
+ Object[] httpServices = httpTracker.getServices();
+
+ for (int i = 0; httpServices != null && i < httpServices.length; i++) {
+ HttpService http = (HttpService)httpServices[i];
+ try {
+ http.unregister(alias);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ bc.ungetService(sr);
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java
new file mode 100644
index 0000000000..db77162b41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java
@@ -0,0 +1,275 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.osgi;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.InetAddress;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+
+import org.apache.tuscany.sca.host.http.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ *
+ */
+public class OSGiServletHost implements ServletHost, BundleActivator {
+ static final String DUMMY_URI = "/_tuscany";
+
+ /**
+ * Default servlet
+ */
+ private static class DefaultServlet extends HttpServlet {
+
+ @Override
+ public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
+ PrintWriter pw = response.getWriter();
+ pw.println("<html><body><h1>Apache Tuscany</h1></body></html>");
+ pw.flush();
+ }
+ }
+
+ private Map<String, Servlet> servlets = new ConcurrentHashMap<String, Servlet>();
+
+ private static final Logger logger = Logger.getLogger(OSGiServletHost.class.getName());
+
+ private String contextPath = "/";
+ private int defaultPortNumber = 8080;
+
+ private ServletContext servletContext;
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+ private HttpServiceWrapper wrapper;
+
+ private static BundleContext bundleContext;
+
+ public void start(BundleContext context) {
+ bundleContext = context;
+ wrapper = new HttpServiceWrapper(bundleContext);
+ wrapper.open();
+
+ HttpServlet defaultServlet = new DefaultServlet();
+ addServletMapping(DUMMY_URI, defaultServlet);
+ // this.servletContext = defaultServlet.getServletContext();
+ }
+
+ public void stop(BundleContext bundleContext) {
+ removeServletMapping(DUMMY_URI);
+ wrapper.close();
+ }
+
+ public void setDefaultPort(int port) {
+ defaultPortNumber = port;
+ }
+
+ public int getDefaultPort() {
+ return defaultPortNumber;
+ }
+
+ public void addServletMapping(String suri, Servlet servlet) 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
+ try {
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(HttpServiceWrapper.SERVLET_URI, suri);
+ ServiceRegistration reg = bundleContext.registerService(Servlet.class.getName(), servlet, props);
+ servlets.put(suri, servlet);
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ }
+
+ logger.info("Added Servlet mapping: " + suri);
+ }
+
+ 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
+ try {
+ return servlets.remove(suri);
+ } catch (Exception e) {
+ throw new ServletMappingException(e);
+ }
+
+ }
+
+ 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) 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;
+ 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;
+ }
+
+ suri = contextPath + suri;
+
+ // Get the Servlet mapped to the given path
+ Servlet servlet = servlets.get(suri);
+ if (servlet != null) {
+ return new ServletRequestDispatcher(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 ServletRequestDispatcher(entry.getKey().substring(contextPath.length()), entry
+ .getValue());
+ } else {
+ if ((suri + "/").startsWith(servletPath)) {
+ return new ServletRequestDispatcher(entry.getKey().substring(contextPath.length()), entry
+ .getValue());
+ }
+ }
+ }
+ }
+
+ // No Servlet found
+ return null;
+ }
+
+ 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 void setAttribute(String name, Object value) {
+ if (servletContext != null) {
+ servletContext.setAttribute(name, value);
+ } else {
+ attributes.put(name, value);
+ }
+ }
+
+ public String getName() {
+ return "osgi";
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/ServletRequestDispatcher.java b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/ServletRequestDispatcher.java
new file mode 100644
index 0000000000..789deeb94e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/ServletRequestDispatcher.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.osgi;
+
+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 ServletRequestDispatcher implements RequestDispatcher {
+ private String servletPath;
+ private Servlet servlet;
+
+ public ServletRequestDispatcher(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) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/java/org/apache/tuscany/sca/http/osgi/OSGiServletHostTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/java/org/apache/tuscany/sca/http/osgi/OSGiServletHostTestCase.java
new file mode 100644
index 0000000000..b38543a7e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/java/org/apache/tuscany/sca/http/osgi/OSGiServletHostTestCase.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.http.osgi;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.net.URL;
+
+import org.apache.tuscany.sca.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;
+
+/**
+ *
+ */
+public class OSGiServletHostTestCase {
+ /** Standard OSGi port property for HTTP service */
+ public static final String HTTP_PORT = "org.osgi.service.http.port";
+
+ /** Standard OSGi port property for HTTPS service */
+ public static final String HTTPS_PORT = "org.osgi.service.http.port.secure";
+
+ private static EquinoxHost host;
+ private static String port;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ port = System.setProperty(HTTP_PORT, "8085");
+ host = new EquinoxHost();
+ BundleContext context = host.start();
+ for (Bundle b : context.getBundles()) {
+ System.out.println(b.getSymbolicName());
+ b.start();
+ }
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (host != null) {
+ host.stop();
+ if (port != null) {
+ System.setProperty(HTTP_PORT, port);
+ } else {
+ System.clearProperty(HTTP_PORT);
+ }
+ }
+ }
+
+ @Test
+ public void testHost() throws IOException {
+ URL url = new URL("http://localhost:8085" + OSGiServletHost.DUMMY_URI);
+ InputStream is = url.openStream();
+ Reader reader = new InputStreamReader(is);
+ char[] content = new char[1024];
+ int len = 0;
+ while (true) {
+ int size = reader.read(content, len, 1024 - len);
+ if (size < 0) {
+ break;
+ }
+ len += size;
+ }
+ Assert.assertTrue(len > 0);
+ String str = new String(content, 0, len);
+ System.out.println(str);
+ Assert.assertEquals("<html><body><h1>Apache Tuscany</h1></body></html>", str.trim());
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/content/test.html b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/content/test.html
new file mode 100644
index 0000000000..9ee377e1ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/content/test.html
@@ -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.
+-->
+<html>
+<body>
+<h1>Hello from Apache Tuscany!</h1>
+</body>
+</html> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/tuscany.keyStore b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http-osgi/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-http/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-http/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-http/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b4ad3f121e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/META-INF/MANIFEST.MF
@@ -0,0 +1,21 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.http;uses:="javax.servlet,
+ javax.servlet.http";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA HTTP Servlet 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: 1225397255593
+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/tags/java/sca/2.0-M4-RC2/modules/host-http/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-http/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/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/tags/java/sca/2.0-M4-RC2/modules/host-http/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-http/pom.xml
new file mode 100644
index 0000000000..2cd779140d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java
new file mode 100644
index 0000000000..3de0b9f5a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java
new file mode 100644
index 0000000000..04b2f4c199
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.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.host.http;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+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 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;
+
+/**
+ * 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 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 {
+ Class<?> cls = sd.loadClass();
+ Constructor<?> ctor = null;
+ try {
+ ctor = cls.getConstructor(ExtensionPointRegistry.class);
+ host = (ServletHost)ctor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ ctor = cls.getConstructor();
+ host = (ServletHost)ctor.newInstance();
+ }
+ if(host instanceof LifeCycleListener) {
+ ((LifeCycleListener) host).start();
+ }
+ } catch (Throwable e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return host;
+ }
+
+ public void addServletMapping(String uri, Servlet servlet) throws ServletMappingException {
+ getServletHost().addServletMapping(uri, servlet);
+ }
+
+ 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) {
+ return getServletHost().getURLMapping(uri);
+ }
+
+ 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() {
+ if (host instanceof LifeCycleListener) {
+ ((LifeCycleListener)host).stop();
+ }
+ }
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ for (ServletHost host : servletHosts) {
+ if (host instanceof LifeCycleListener) {
+ ((LifeCycleListener)host).stop();
+ }
+ }
+ servletHosts.clear();
+ registry = null;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java
new file mode 100644
index 0000000000..4dfa1dd8a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.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.host.http;
+
+import java.net.URL;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+
+/**
+ * Default implementation of an extensible Servlet host.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleServletHost implements ServletHost {
+
+ private ServletHostExtensionPoint servletHosts;
+
+ public ExtensibleServletHost(ServletHostExtensionPoint servletHosts) {
+ this.servletHosts = servletHosts;
+ }
+
+ public void setDefaultPort(int port) {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ for (ServletHost servletHost: servletHosts.getServletHosts()) {
+ servletHost.setDefaultPort(port);
+ }
+ }
+
+ private ServletHost getDefaultServletHost() {
+ return servletHosts.getServletHosts().get(0);
+ }
+
+ public int getDefaultPort() {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ return getDefaultServletHost().getDefaultPort();
+ }
+
+ public void addServletMapping(String uri, Servlet servlet) throws ServletMappingException {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ // TODO implement selection of the correct Servlet host based on the mapping
+ // For now just select the first one
+ getDefaultServletHost().addServletMapping(uri, servlet);
+ }
+
+ public Servlet getServletMapping(String uri) throws ServletMappingException {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ // 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 {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ // 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 {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ // 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() {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ // 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) {
+ if (servletHosts.getServletHosts().isEmpty()) {
+ throw new ServletMappingException("No servlet host available");
+ }
+
+ return getDefaultServletHost().getURLMapping(uri);
+ }
+
+ 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();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java
new file mode 100644
index 0000000000..dffc1e73d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.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.http;
+
+import java.net.URL;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+
+/**
+ * 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$
+ */
+public interface ServletHost {
+
+ /**
+ * 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
+ * @throws ServletMappingException
+ */
+ void addServletMapping(String uri, Servlet servlet) 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);
+
+ /**
+ * 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);
+
+ String getName();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java
new file mode 100644
index 0000000000..fbd085ba2b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.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.http;
+
+import java.util.List;
+
+/**
+ * An extension point for Servlet hosts.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ServletHostExtensionPoint {
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java b/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java
new file mode 100644
index 0000000000..ae66c44c3e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1a782368bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.jetty;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Jetty 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: 1225397258562
+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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/pom.xml
new file mode 100644
index 0000000000..3b9e19fd00
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java
new file mode 100644
index 0000000000..4f5bfb3c62
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java
new file mode 100644
index 0000000000..be56bdb682
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
new file mode 100644
index 0000000000..b966e38a29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java
@@ -0,0 +1,519 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Set;
+import java.util.Map.Entry;
+import java.util.logging.Logger;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+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.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;
+ private int defaultPort = portDefault;
+ public static int portDefault = 8080;
+
+ /**
+ * 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.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());
+ 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) {
+ connector.setProtocol("TLS");
+ 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 void addServletMapping(String suri, Servlet servlet) 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 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);
+ configureSSL(sslConnector);
+ server.setConnectors(new Connector[] {sslConnector});
+ } else {
+ SelectChannelConnector selectConnector = new SelectChannelConnector();
+ selectConnector.setPort(portNumber);
+ 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
+ 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);
+ }
+
+ 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;
+ }
+
+ // 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
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
new file mode 100644
index 0000000000..2ab9e46b10
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
@@ -0,0 +1,332 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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;
+
+/**
+ * @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);
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/content/test.html b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/tuscany.keyStore b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..915d62fa41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/META-INF/MANIFEST.MF
@@ -0,0 +1,29 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.http.jetty;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Jetty7 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: 1225397258562
+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.eclipse.jetty.util.component;version="7.0.0.v20091005",
+ org.eclipse.jetty;version="7.0.0.v20091005",
+ org.eclipse.jetty.handler;version="7.0.0.v20091005",
+ org.eclipse.jetty.nio;version="7.0.0.v20091005",
+ org.eclipse.jetty.security;version="7.0.0.v20091005",
+ org.eclipse.jetty.servlet;version="7.0.0.v20091005",
+ org.eclipse.jetty.util.log;version="7.0.0.v20091005",
+ org.eclipse.jetty.util.resource;version="7.0.0.v20091005",
+ org.eclipse.jetty.util.thread;version="7.0.0.v20091005"
+Bundle-SymbolicName: org.apache.tuscany.sca.host.jetty7
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/pom.xml
new file mode 100644
index 0000000000..88aeb58d2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-host-jetty7</artifactId>
+ <name>Apache Tuscany SCA Jetty7 Servlet Host Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <version>7.0.0.v20091005</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <version>7.0.0.v20091005</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyDefaultServlet.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyDefaultServlet.java
new file mode 100644
index 0000000000..dc6f155f80
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/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.jetty7;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.util.resource.Resource;
+import org.eclipse.jetty.util.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/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyServer.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyServer.java
new file mode 100644
index 0000000000..ae8e196147
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyServer.java
@@ -0,0 +1,520 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.jetty7;
+
+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.Set;
+import java.util.Map.Entry;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+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.ServletHost;
+import org.apache.tuscany.sca.host.http.ServletMappingException;
+import org.apache.tuscany.sca.work.WorkScheduler;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ContextHandler;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.servlet.ServletMapping;
+import org.eclipse.jetty.util.log.JavaUtilLog;
+import org.eclipse.jetty.util.log.Log;
+import org.eclipse.jetty.util.log.Logger;
+import org.eclipse.jetty.util.thread.ThreadPool;
+
+/**
+ * Implements an HTTP transport service using Jetty.
+ *
+ * @version $Rev$ $Date$
+ */
+public class JettyServer implements ServletHost, LifeCycleListener {
+ private static final java.util.logging.Logger logger = java.util.logging.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;
+ private int defaultPort = portDefault;
+ public static int portDefault = 8080;
+
+ /**
+ * 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 Logger jettyLogger;
+
+ public JettyServer(ExtensionPointRegistry registry) {
+ this(registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(WorkScheduler.class));
+ }
+
+ protected JettyServer(WorkScheduler workScheduler) {
+ 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());
+ 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) {
+ connector.setProtocol("TLS");
+ 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 void addServletMapping(String suri, Servlet servlet) 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 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);
+ configureSSL(sslConnector);
+ server.setConnectors(new Connector[] {sslConnector});
+ } else {
+ SelectChannelConnector selectConnector = new SelectChannelConnector();
+ selectConnector.setPort(portNumber);
+ 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.setHandler(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
+ 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);
+ }
+
+ 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;
+ }
+
+ // 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 JavaUtilLog(JettyServer.class.getName());
+ Log.setLog(jettyLogger);
+ } catch (Throwable e) {
+ // Ignore
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost
new file mode 100644
index 0000000000..99278c123b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/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.jetty7.JettyServer;name=jetty7,ranking=50
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/java/org/apache/tuscany/sca/http/jetty7/JettyServerTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/java/org/apache/tuscany/sca/http/jetty7/JettyServerTestCase.java
new file mode 100644
index 0000000000..ff6894e858
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/java/org/apache/tuscany/sca/http/jetty7/JettyServerTestCase.java
@@ -0,0 +1,335 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.jetty7;
+
+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.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.http.jetty7.JettyServer;
+import org.apache.tuscany.sca.work.NotificationListener;
+import org.apache.tuscany.sca.work.WorkScheduler;
+
+/**
+ * @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);
+ }
+
+ 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");
+ System.setProperty("org.eclipse.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.clearProperty("org.eclipse.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/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/content/test.html b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/content/test.html
new file mode 100644
index 0000000000..f4b79d7f01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/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/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/tuscany.keyStore b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/tuscany.keyStore
new file mode 100644
index 0000000000..7ea23f7ff4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-jetty7/src/test/resources/tuscany.keyStore
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-rmi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..686ee33f4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.host.rmi;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA RMI 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: 1225397321468
+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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/pom.xml
new file mode 100644
index 0000000000..635cba7222
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java
new file mode 100644
index 0000000000..cc819d194c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.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.host.rmi;
+
+import java.net.URI;
+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 void 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);
+ } 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) {
+ this.uriStr = uriStr;
+ URI uri = URI.create(uriStr);
+ host = uri.getHost();
+ if (host == null) {
+ 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;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java
new file mode 100644
index 0000000000..541ee8ba06
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java
new file mode 100644
index 0000000000..2f3e2311ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 void registerService(String uri, Remote serviceObject) throws RMIHostException, RMIHostRuntimeException {
+ if (rmiHosts.getRMIHosts().isEmpty()) {
+ throw new RMIHostException("No RMI host available");
+ }
+ getDefaultHost().registerService(uri, serviceObject);
+ }
+
+ public void unregisterService(String uri) throws RMIHostException, RMIHostRuntimeException {
+ if (rmiHosts.getRMIHosts().isEmpty()) {
+ throw new RMIHostException("No RMI host 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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java
new file mode 100644
index 0000000000..bf8659c254
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.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.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
+ * @throws RMIHostException
+ * @throws RMIHostRuntimeException
+ */
+ void 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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java
new file mode 100644
index 0000000000..5ea46b9e0b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java
new file mode 100644
index 0000000000..40d6013940
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java
new file mode 100644
index 0000000000..dfbcc62939
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java
new file mode 100644
index 0000000000..763e5c1315
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java
new file mode 100644
index 0000000000..1164c33a16
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..fca93beabf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,25 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Webapp Host
+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.host.webapp
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-webapp/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/NOTICE
new file mode 100644
index 0000000000..f5efe99703
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/NOTICE
@@ -0,0 +1,7 @@
+${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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/pom.xml
new file mode 100644
index 0000000000..af90c58fad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-http</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java
new file mode 100644
index 0000000000..4ad9519ad8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.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.host.webapp;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+
+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.DefaultServletHostExtensionPoint;
+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;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+
+public class ServletHostHelper {
+ 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 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("/")) {
+ path = "/" + 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 {
+ 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();
+ configuration.setDomainURI(factory.getDomainURI());
+ Enumeration<String> names = servletContext.getAttributeNames();
+ while (names.hasMoreElements()) {
+ String name = names.nextElement();
+ if (name.startsWith("contribution.")) {
+ String contrib = (String) servletContext.getAttribute(name);
+ if (contrib != null) {
+ configuration.addContribution(getResource(servletContext, contrib));
+ }
+ }
+ }
+ if (configuration.getContributions().isEmpty()) {
+ // TODO: Which path should be the default root
+ configuration.addContribution(getResource(servletContext, "/"));
+ }
+ URL composite = getResource(servletContext, "/WEB-INF/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("/")).getName();
+ }
+ configuration.setURI(nodeURI);
+ String domainURI = (String) servletContext.getAttribute("domain.uri");
+ if (domainURI != null) {
+ configuration.setDomainURI(domainURI);
+ }
+ }
+ return configuration;
+ }
+
+ public static ServletHost init(final ServletContext servletContext) {
+ Node node = (Node)servletContext.getAttribute(SCA_NODE_ATTRIBUTE);
+ if (node == null) {
+ try {
+ String domainName = (String)servletContext.getAttribute(DOMAIN_NAME_ATTR);
+ if (domainName != null) {
+ factory = NodeFactory.getInstance(domainName);
+ } else {
+ factory = NodeFactory.newInstance();
+ }
+ for (Enumeration<String> e = servletContext.getInitParameterNames(); e.hasMoreElements();) {
+ String name = e.nextElement();
+ String value = servletContext.getInitParameter(name);
+ servletContext.setAttribute(name, value);
+ }
+ node = createNode(servletContext);
+ servletContext.setAttribute(SCA_NODE_ATTRIBUTE, node);
+ getServletHost(node).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();
+ }
+ });
+ } catch (ServletException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return getServletHost(node);
+ }
+
+ private static WebAppServletHost getServletHost(Node node) {
+ NodeImpl nodeImpl = (NodeImpl)node;
+ ExtensionPointRegistry eps = nodeImpl.getExtensionPoints();
+ ServletHostExtensionPoint servletHosts = eps.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (hosts == null || hosts.size() < 1) {
+ throw new IllegalStateException("No ServletHost found");
+ }
+ for (ServletHost servletHost : hosts) {
+ if ("webapp".equals(servletHost.getName())) {
+ if(servletHost instanceof DefaultServletHostExtensionPoint.LazyServletHost) {
+ return (WebAppServletHost) ((DefaultServletHostExtensionPoint.LazyServletHost) servletHost).getServletHost();
+ } else if(servletHost instanceof WebAppServletHost) {
+ return (WebAppServletHost) servletHost;
+ }
+ }
+ }
+ throw new IllegalStateException("No WebApp Servlet host is configured");
+ }
+
+ private static Node createNode(final ServletContext servletContext) throws ServletException {
+ NodeConfiguration configuration;
+ try {
+ configuration = getNodeConfiguration(servletContext);
+ } catch (IOException e) {
+ throw new ServletException(e);
+ }
+ Node node = factory.createNode(configuration).start();
+ return node;
+ }
+
+ public static void stop(ServletContext servletContext) {
+ Node node = (Node)servletContext.getAttribute(ServletHostHelper.SCA_NODE_ATTRIBUTE);
+ if (node != null) {
+ node.stop();
+ servletContext.setAttribute(ServletHostHelper.SCA_NODE_ATTRIBUTE, null);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
new file mode 100644
index 0000000000..62c238e135
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 {
+ ServletHostHelper.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 {
+ ServletHostHelper.stop(event.getServletContext());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ inited = false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
new file mode 100644
index 0000000000..72a76a789e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = ServletHostHelper.init(context);
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ context.log(e.getMessage(), e);
+ throw new ServletException(e);
+ }
+ }
+
+ public void destroy() {
+ ServletHostHelper.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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java
new file mode 100644
index 0000000000..76cce939ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
new file mode 100644
index 0000000000..4e32d8bcad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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 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 void addServletMapping(String suri, Servlet servlet) 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
+ servlets.put(suri, servlet);
+
+ logger.info("Added Servlet mapping: " + suri);
+ }
+
+ 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
+ return servlets.remove(suri);
+ }
+
+ 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) 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;
+ 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 {
+
+ servletContext = config.getServletContext();
+
+ for (String name : tempAttributes.keySet()) {
+ servletContext.setAttribute(name, tempAttributes.get(name));
+ }
+
+ ServletHostHelper.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
+ ServletHostHelper.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);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/LICENSE
new file mode 100644
index 0000000000..baba9ca048
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5e40de7a52
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,61 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA BPEL ODE Implementation Extension
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bnd-LastModified: 1225397447609
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-ClassPath: .,ode-bpel-epr-1.3.2.jar,ode-bpel-store-1.3.2.jar,
+ ode-bpel-dao-1.3.2.jar,ode-dao-jpa-1.3.2.jar,
+ ode-bpel-runtime-1.3.2.jar,ode-bpel-api-1.3.2.jar,
+ ode-scheduler-simple-1.3.2.jar,ode-utils-1.3.2.jar,
+ ode-bpel-compiler-1.3.2.jar,ode-bpel-schemas-1.3.2.jar,
+ ode-bpel-obj-1.3.2.jar,ode-jacob-1.3.2.jar,ode-jacob-ap-1.3.2.jar,
+ geronimo-jta_1.1_spec-1.1.jar,geronimo-transaction-2.0.1.jar,
+ persistence-api-1.0.jar,ode-agents-1.3.2.jar,
+ ode-dao-hibernate-1.3.2.jar,
+ geronimo-connector-2.0.1.jar,openjpa-1.3.0-SNAPSHOT.jar
+Bundle-Description: Apache Tuscany SCA BPEL ODE Implementation Extensi
+ on
+Import-Package: javax.resource.spi,
+ javax.transaction;version="1.1.0",
+ javax.wsdl;resolution:=optional,
+ javax.xml.namespace;resolution:=optional,
+ javax.xml.transform,
+ javax.xml.transform.dom,
+ javax.xml.transform.stream,
+ org.apache.commons.logging;resolution:=optional,
+ org.apache.geronimo.transaction.manager,
+ org.apache.ode.bpel.compiler,
+ org.apache.ode.bpel.dao,
+ org.apache.ode.bpel.engine,
+ org.apache.ode.bpel.evt,
+ org.apache.ode.bpel.iapi,
+ org.apache.ode.bpel.memdao,
+ org.apache.ode.il.config,
+ org.apache.ode.il.dbutil,
+ org.apache.ode.scheduler.simple,
+ org.apache.ode.utils,
+ 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.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;resolution:=optional;common=split,
+ org.oasisopen.sca.annotation;version="2.0",
+ org.w3c.dom;resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.bpel.ode
+Bundle-DocURL: http://www.apache.org/
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/NOTICE
new file mode 100644
index 0000000000..a2f696be26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/pom.xml
new file mode 100644
index 0000000000..2a1749b1e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java
new file mode 100644
index 0000000000..d812a64e1c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.axis2.BindingContextImpl;
+//import org.apache.ode.axis2.EndpointReferenceContextImpl;
+//import org.apache.ode.axis2.MessageExchangeContextImpl;
+//import org.apache.ode.axis2.EndpointReferenceContextImpl;
+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.Endpoint;
+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 {
+ 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 {
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader bpelcl = this.getClass().getClassLoader();
+ try{
+ // Switch TCCL - under OSGi this causes the TCCL to be set to the Bundle
+ // classloader - this is then used by 3rd party code from ODE and its dependencies
+ if( bpelcl != tccl ) Thread.currentThread().setContextClassLoader(bpelcl);
+ 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);
+ }
+
+ // Added MJE, 24/06/2009 - for 1.3.2 version of ODE
+ _scheduler.start();
+ // end of addition
+
+ __log.info("ODE BPEL server started.");
+ _initialized = true;
+ } finally {
+ // Restore the TCCL if we changed it
+ if( bpelcl != tccl ) Thread.currentThread().setContextClassLoader(tccl);
+ }
+ }
+
+ /**
+ * 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;
+ // TODO - provide a system property / environment variable to set the path to the DB
+
+ URL dbLocation = getClass().getClassLoader().getResource("jpadb");
+ if (dbLocation == null) {
+ throw new ODEInitializationException("Couldn't find database in the classpath");
+ }
+ // 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();
+ 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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java
new file mode 100644
index 0000000000..079a0f96f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java
new file mode 100644
index 0000000000..55bde26c08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.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.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.Endpoint;
+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.RuntimeWire;
+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 );
+ RuntimeWire runtimeWire = getRuntimeWire( runtimeComponentReference, partnerRoleMessageExchange );
+ // convert operations
+ Operation operation =
+ findOperation(partnerRoleMessageExchange.getOperation().getName(), runtimeComponentReference);
+
+ /*
+ 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 = runtimeWire.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 RuntimeWire getRuntimeWire( 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());
+ RuntimeWire 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 componentReference.getRuntimeWire(componentReference.getEndpointReferences().get(0));
+ } // end if
+ } // end method getRuntimeWire
+
+ private RuntimeWire 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 (RuntimeWire wire : componentReference.getRuntimeWires()) {
+ if (wire.getEndpointReference().getBinding().getName().equals(endpoint.getBinding().getName())) {
+ return wire;
+ }
+ } // end for
+
+ // if no match, look for callback binding with same type as service binding
+ for (RuntimeWire wire : componentReference.getRuntimeWires()) {
+ if (wire.getEndpointReference().getBinding().getClass() == endpoint.getBinding().getClass()) {
+ return wire;
+ }
+ } // end for
+
+ // no suitable callback wire was found
+ return null;
+ } // end method selectCallbackWire
+
+ private RuntimeWire 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);
+ RuntimeWire wire = ref.getRuntimeWires().get(0);
+
+ return wire;
+ } 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, RuntimeComponentReference runtimeComponentReference) {
+ Operation reseultOperation = null;
+
+ for(Operation operation : runtimeComponentReference.getInterfaceContract().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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
new file mode 100644
index 0000000000..19e7d3e913
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java
@@ -0,0 +1,756 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.assembly.Service;
+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.
+ if( rewritten ) {
+ 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 as the "service"
+ // name, combined with http://tuscany.apache.org to make a QName
+ for( Reference reference : theReferences ) {
+ // 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( reference.getName(),
+ 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<Service> theServices = implementation.getServices();
+ List<ComponentService> theServices = component.getServices();
+ // Create an endpoint for each reference, using the reference name as the "service"
+ // name, combined with http://tuscany.apache.org to make a QName
+ for( ComponentService service : theServices ) {
+ // MJE 14/07/2009 - added componentURI to the service name to get unique service name
+ provideEndpoints.put( service.getName(),
+ 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 immediate child of the insertion point
+ insertionElement.insertBefore( initializer, insertionElement.getFirstChild() );
+
+ } // 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.createElement("literal");
+ literalElement.setTextContent(valueText);
+ Element fromElement = bpelDOM.createElement("from");
+ fromElement.appendChild(literalElement);
+ Element toElement = bpelDOM.createElement("to");
+ Attr variableAttribute = bpelDOM.createAttribute("variable");
+ variableAttribute.setValue( property.getName() );
+ toElement.setAttributeNode( variableAttribute );
+ Element copyElement = bpelDOM.createElement("copy");
+ copyElement.appendChild(fromElement);
+ copyElement.appendChild(toElement);
+ Element assignElement = bpelDOM.createElement("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
+
+ private static String SEQUENCE_ELEMENT = "sequence";
+ /**
+ * Determine if an Element is a BPEL Activity element which can have an Assign
+ * inserted following it
+ * @param element - the Element
+ * @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 <sequence/> elements count
+ // TODO - extend this to cover other insertable cases
+ if( SEQUENCE_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();
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java
new file mode 100644
index 0000000000..68492a5dbb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.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.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.tuscany.sca.assembly.Endpoint;
+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.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;
+
+/**
+ * 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() ) {
+ if (endpoint.getInterfaceContract() != null) {
+ endpoint.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
+ } // end for
+ } // end for
+
+ for (Reference reference: component.getReferences()) {
+ reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ /* for( EndpointReference epr : reference.getEndpointReferences() ) {
+ epr.getInterfaceContract().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
+
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ ClassLoader bpelcl = this.getClass().getClassLoader();
+
+ try {
+ // Switch TCCL - under OSGi this causes the TCCL to be set to the Bundle
+ // classloader - this is then used by 3rd party code from ODE and its dependencies
+ if( bpelcl != tccl ) Thread.currentThread().setContextClassLoader(bpelcl);
+
+ 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 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( bpelcl != tccl ) 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 !!!");
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java
new file mode 100644
index 0000000000..dfe11600f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = 2000L;
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml
new file mode 100644
index 0000000000..571aa37d58
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl
new file mode 100644
index 0000000000..e768707ccd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..1799a5ebd3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel-runtime/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..82b3c09723
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/LICENSE
new file mode 100644
index 0000000000..baba9ca048
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5e88dde880
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/META-INF/MANIFEST.MF
@@ -0,0 +1,34 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA BPEL Implementation Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397433843
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/NOTICE
new file mode 100644
index 0000000000..a2f696be26
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/pom.xml
new file mode 100644
index 0000000000..184953dd05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-wsdl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java
new file mode 100644
index 0000000000..9f8f9c0e9a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java
new file mode 100644
index 0000000000..f8f7ee0ae2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.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;
+
+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);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java
new file mode 100644
index 0000000000..ac02b696cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java
new file mode 100644
index 0000000000..ad8b3a7bcf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.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.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;
+
+/**
+ * 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;
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
new file mode 100644
index 0000000000..6b12f6666e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java
@@ -0,0 +1,354 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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");
+ }
+
+ // 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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java
new file mode 100644
index 0000000000..6a2d6310c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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 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 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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..5b53ed1ee0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.bpel,model=org.apache.tuscany.sca.implementation.bpel.BPELImplementation
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties
new file mode 100644
index 0000000000..b6d8bdc0f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java
new file mode 100644
index 0000000000..1ef972342a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java
new file mode 100644
index 0000000000..c56ab48854
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903\" 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/200903\" 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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel
new file mode 100644
index 0000000000..8cf91adc2c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl
new file mode 100644
index 0000000000..610bda3cc4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ab4d626d6e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,62 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Java Implementation Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397187218
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/pom.xml
new file mode 100644
index 0000000000..a319078096
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
new file mode 100644
index 0000000000..ba71abd826
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.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.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;
+
+ public ReflectiveInstanceFactory(Constructor<T> ctr,
+ ObjectFactory<?>[] ctrArgs,
+ Injector<T>[] injectors,
+ EventInvoker<T> initInvoker,
+ EventInvoker<T> destroyInvoker) {
+ this.ctr = ctr;
+ this.ctrArgs = ctrArgs;
+ this.injectors = injectors;
+ 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) {
+ destroyInvoker.invokeEvent(instance);
+ throw new ObjectCreationException("Exception invoking injector", e);
+ }
+ }
+ }
+
+ return new ReflectiveInstanceWrapper<T>(instance, initInvoker, destroyInvoker);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
new file mode 100644
index 0000000000..7c96606cf6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.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.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.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;
+
+ public ReflectiveInstanceWrapper(T instance, EventInvoker<T> initInvoker, EventInvoker<T> destroyInvoker) {
+ this.instance = instance;
+ this.initInvoker = initInvoker;
+ this.destroyInvoker = destroyInvoker;
+ }
+
+ 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);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java
new file mode 100644
index 0000000000..dd454be7c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.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.injection;
+
+import java.lang.reflect.Field;
+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 {
+ try {
+ field.set(instance, objectFactory.getInstance());
+ } catch (IllegalAccessException e) {
+ throw new ObjectCreationException("Field is not accessible [" + field + "]", e);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java
new file mode 100644
index 0000000000..fbc2ace341
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.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;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java
new file mode 100644
index 0000000000..4d062859b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.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.injection;
+
+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;
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
new file mode 100644
index 0000000000..01c3b148f8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
@@ -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.
+ */
+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;
+ }
+
+ /**
+ * Introspect the property
+ * @param javaElement
+ * @return
+ */
+ private DataType<?> introspect(JavaElementImpl javaElement) {
+ DataType<XMLType> dt =
+ new DataTypeImpl<XMLType>(null, javaElement.getType(), javaElement.getGenericType(), XMLType.UNKNOWN);
+ mediator.getDataBindings().introspectType(dt, null);
+ return dt;
+ }
+
+ 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) {
+ ObjectFactory<B> factory = this.createValueFactory(property, property.getValue(), type);
+ return factory.getInstance();
+ }
+
+ 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()));
+ 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) {
+ // The root is the property element
+ Element rootElement = document.getDocumentElement();
+ List<Node> propValues = new ArrayList<Node>();
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java
new file mode 100644
index 0000000000..baf9eb9cc1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.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.java.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+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 {
+ try {
+ method.invoke(instance, objectFactory.getInstance());
+ } 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);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java
new file mode 100644
index 0000000000..602dc5d31a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.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.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.RuntimeWire;
+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;
+ }
+
+ public void process(RuntimeWire wire) {
+ addCallbackInterfaceInterceptors(wire);
+ }
+
+ private void addCallbackInterfaceInterceptors(RuntimeWire wire) {
+ Contract contract = wire.getEndpointReference().getReference();
+ if (!(contract instanceof RuntimeComponentReference)) {
+ return;
+ }
+ RuntimeComponent component = (RuntimeComponent) wire.getEndpointReference().getComponent();
+ if (component == null) {
+ return;
+ }
+ Implementation implementation = component.getImplementation();
+ if (!(implementation instanceof JavaImplementation)) {
+ return;
+ }
+ JavaImplementation javaImpl = (JavaImplementation)implementation;
+ Endpoint callbackEndpoint = wire.getEndpointReference().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 : wire.getInvocationChains()) {
+ chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor());
+ }
+ }
+ }
+ }
+
+ 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());
+ implType.setConversational(iface.isConversational());
+ return interfaceContractMapper.isCompatible(iface, implType);
+ } catch (InvalidInterfaceException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
new file mode 100644
index 0000000000..6929b5d0ca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.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.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.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.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+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.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+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;
+
+ 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;
+ }
+
+ InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
+ return instanceFactoryProvider.createFactory().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() {
+ if (!instanceFactoryProvider.getImplementation().getCallbackMembers().isEmpty()) {
+ Map<String, List<RuntimeWire>> callbackWires = new HashMap<String, List<RuntimeWire>>();
+ for (ComponentService service : component.getServices()) {
+
+ RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
+ if (callbackReference != null) {
+ List<RuntimeWire> wires = callbackReference.getRuntimeWires();
+ if (!wires.isEmpty()) {
+ callbackWires.put(wires.get(0).getEndpointReference().getInterfaceContract().getInterface().toString(),
+ wires);
+ }
+ }
+ }
+
+ for (Map.Entry<String, Collection<JavaElementImpl>> entry : instanceFactoryProvider.getImplementation()
+ .getCallbackMembers().entrySet()) {
+ List<RuntimeWire> 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)) {
+ instanceFactoryProvider.getInjectionSites().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<RuntimeWire> wireList = null;
+ for (ComponentReference reference : component.getReferences()) {
+ if (reference.getName().equals(ref.getName())) {
+ wireList = ((RuntimeComponentReference)reference).getRuntimeWires();
+ 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, component,
+ (RuntimeComponentReference)wireList.get(i)
+ .getEndpointReference().getReference(), wireList.get(i)
+ .getEndpointReference());
+ } 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, component,
+ (RuntimeComponentReference)componentReference, wireList.get(0).getEndpointReference());
+ } 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();
+ }
+
+ 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) throws NoSuchMethodException {
+ Class<?> implClass = instanceFactoryProvider.getImplementationClass();
+
+ Method method = JavaInterfaceUtil.findMethod(implClass, operation);
+ return new JavaImplementationInvoker(operation, method, component);
+ }
+
+ 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, RuntimeWire 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, 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
new file mode 100644
index 0000000000..476ed9ac83
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.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.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.InstanceWrapper;
+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.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+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.RuntimeComponent;
+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, DataExchangeSemantics {
+ protected Operation operation;
+ protected Method method;
+ protected boolean allowsPBR;
+
+ @SuppressWarnings("unchecked")
+ protected final ScopeContainer scopeContainer;
+
+ public JavaImplementationInvoker(Operation operation, Method method, RuntimeComponent component) {
+ 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);
+ }
+
+ public JavaImplementationInvoker(Operation operation, RuntimeComponent component) {
+ // used if the method can't be computed statically in advance
+ this.operation = operation;
+ this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Message invoke(Message msg) {
+ Operation op = msg.getOperation();
+ if (op == null) {
+ op = this.operation;
+ }
+ ConversationSequence sequence = op.getConversationSequence();
+ Object payload = msg.getBody();
+
+ Object contextId = null;
+
+ EndpointReference from = msg.getFrom();
+ /* TODO - EPR - not required for OASIS
+ ReferenceParameters parameters = null;
+ if (from != null) {
+ parameters = from.getReferenceParameters();
+ }
+
+ // check what sort of context is required
+ if (scopeContainer != null) {
+ Scope scope = scopeContainer.getScope();
+ if (scope == Scope.REQUEST) {
+ contextId = Thread.currentThread();
+ } else if (scope == Scope.CONVERSATION && parameters != null) {
+ contextId = parameters.getConversationID();
+ }
+ }
+ */
+
+ 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);
+
+ // detects whether the scope container has created a conversation Id. This will
+ // happen in the case that the component has conversational scope but only the
+ // callback interface is conversational. Or in the callback case if the service interface
+ // is conversational and the callback interface isn't. If we are in this situation we need
+ // to get the contextId of this component and remove it after we have invoked the method on
+ // it. It is possible that the component instance will not go away when it is removed below
+ // because a callback conversation will still be holding a reference to it
+ /* TODO - EPR - not required for OASIS
+ boolean removeTemporaryConversationalComponentAfterCall = false;
+ if (parameters != null && (contextId == null) && (parameters.getConversationID() != null)) {
+ contextId = parameters.getConversationID();
+ removeTemporaryConversationalComponentAfterCall = true;
+ }
+ */
+
+ 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());
+ }
+ }
+
+ Object ret;
+ if (payload != null && !payload.getClass().isArray()) {
+ ret = imethod.invoke(instance, payload);
+ } else {
+ ret = imethod.invoke(instance, (Object[])payload);
+ }
+
+ scopeContainer.returnWrapper(wrapper, contextId);
+
+ /* TODO - EPR - not required for OASIS
+ if ((sequence == ConversationSequence.CONVERSATION_END) || (removeTemporaryConversationalComponentAfterCall)) {
+ // if end conversation, or we have the special case where a conversational
+ // object was created to service the stateless half of a stateful component
+ scopeContainer.remove(contextId);
+ parameters.setConversationID(null);
+ }
+ */
+
+ 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 (sequence != ConversationSequence.CONVERSATION_NONE ){
+ try {
+// // If the exception is not a business exception then end the conversation
+// boolean businessException = false;
+//
+// for (DataType dataType : operation.getFaultTypes()){
+// if ((dataType.getPhysical() == e.getCause().getClass()) &&
+// (contextId != null) ){
+// businessException = true;
+// break;
+// }
+// }
+
+ if (!isChecked && contextId != null) {
+ scopeContainer.remove(contextId);
+ /* TODO - EPR - not required for OASIS
+ parameters.setConversationID(null);
+ */
+ }
+ } catch (Exception ex){
+ // TODO - sure what the best course of action is here. We have
+ // a system exception in the middle of a business exception
+ }
+ }
+ if (!isChecked) {
+ if (cause instanceof RuntimeException) {
+ throw (RuntimeException)cause;
+ }
+ if (cause instanceof Error) {
+ throw (Error)cause;
+ } else {
+ throw new ServiceRuntimeException(cause.getMessage(), cause);
+ }
+ }
+
+ } catch (Exception e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+ public boolean allowsPassByReference() {
+ return allowsPBR;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
new file mode 100644
index 0000000000..55765ef6e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.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.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);
+ } 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());
+ } catch (NoSuchMethodException e1) {
+ throw new IllegalArgumentException(e1);
+ }
+ } else {
+ return new JavaImplementationInvoker(operation, componentContextProvider.getComponent());
+ }
+ }
+ }
+
+ 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();
+ }
+
+ public long getMaxAge() {
+ return implementation.getMaxAge();
+ }
+
+ public long getMaxIdleTime() {
+ return implementation.getMaxIdleTime();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
new file mode 100644
index 0000000000..36d9878fd9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 = new ExtensibleProxyFactory(proxyFactories);
+ }
+
+ /*
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java
new file mode 100644
index 0000000000..7fcfaad615
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.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.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>();
+
+ 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>();
+ }
+
+ 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();
+ return new ReflectiveInstanceFactory<T>((Constructor<T>)definition.getConstructor().getConstructor(),
+ initArgs, injectors, 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() {
+ // work around JDK1.5 issue with allocating generic arrays
+ Injector<T>[] injectors = new Injector[injectionSites.size()];
+
+ int i = 0;
+ for (JavaElementImpl element : injectionSites) {
+ 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 factories
+ */
+ Map<JavaElementImpl, Object> getFactories() {
+ return factories;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml
new file mode 100644
index 0000000000..14d99e8b02
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:implementationType type="sca:implementation.java" mayProvide="" alwaysProvides=""/>
+
+ </sca:definitions>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..517aaac39f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/META-INF/MANIFEST.MF
@@ -0,0 +1,47 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Java Implementation Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397153500
+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.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.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/pom.xml
new file mode 100644
index 0000000000..283a76cb02
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/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-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java
new file mode 100644
index 0000000000..c8b7c072ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.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.java;
+
+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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
new file mode 100644
index 0000000000..f98a617925
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java
new file mode 100644
index 0000000000..2198a632c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java
new file mode 100644
index 0000000000..df76d3ea4e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java
new file mode 100644
index 0000000000..e748a5f6fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java
new file mode 100644
index 0000000000..d3c9c16f48
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.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.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);
+
+ /**
+ * @return the maxAge
+ */
+ long getMaxAge();
+
+ /**
+ * @param maxAge the maxAge to set
+ */
+ void setMaxAge(long maxAge);
+
+ /**
+ * @return the maxIdleTime
+ */
+ long getMaxIdleTime();
+
+ /**
+ * @param maxIdleTime the maxIdleTime to set
+ */
+ void setMaxIdleTime(long maxIdleTime);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java
new file mode 100644
index 0000000000..8228c80372
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java
new file mode 100644
index 0000000000..80911a9552
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java
new file mode 100644
index 0000000000..19a9f38549
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java
new file mode 100644
index 0000000000..c977736630
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java
new file mode 100644
index 0000000000..0d9187c14f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.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.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;
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java
new file mode 100644
index 0000000000..6cb5e3730b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.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.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 extension : visitors) {
+ extension.visitClass(clazz, type);
+ }
+
+ for (Constructor<?> constructor : clazz.getConstructors()) {
+ for (JavaClassVisitor extension : visitors) {
+ extension.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()) {
+ extension.visitConstructorParameter(p, type);
+ }
+ }
+ }
+ }
+
+ Set<Field> fields = JavaIntrospectionHelper.getAllPublicAndProtectedFields(clazz, true);
+ for (Field field : fields) {
+ for (JavaClassVisitor extension : visitors) {
+ extension.visitField(field, type);
+ }
+ }
+
+ // Check if any private fields have illegal annotations that should be raised as errors
+ Set<Field> privateFields = JavaIntrospectionHelper.getPrivateFields(clazz);
+ for (Field field : privateFields) {
+ for (JavaClassVisitor processor : visitors) {
+ processor.visitField(field, type);
+ }
+ }
+
+ Set<Method> methods = JavaIntrospectionHelper.getAllUniquePublicProtectedMethods(clazz, true);
+ for (Method method : methods) {
+ for (JavaClassVisitor processor : visitors) {
+ processor.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) {
+ for (JavaClassVisitor processor : visitors) {
+ processor.visitMethod(method, type);
+ }
+ }
+
+ Class<?> superClass = clazz.getSuperclass();
+ if (superClass != null) {
+ visitSuperClass(superClass, type);
+ }
+
+ for (JavaClassVisitor extension : visitors) {
+ extension.visitEnd(clazz, type);
+ }
+ }
+
+ private void visitSuperClass(Class<?> clazz, JavaImplementation type) throws IntrospectionException {
+ if (!Object.class.equals(clazz)) {
+ for (JavaClassVisitor extension : visitors) {
+ extension.visitSuperClass(clazz, type);
+ }
+ clazz = clazz.getSuperclass();
+ if (clazz != null) {
+ visitSuperClass(clazz, type);
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
new file mode 100644
index 0000000000..aefc5c7e6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.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.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.extensibility.ServiceDiscovery;
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java
new file mode 100644
index 0000000000..9e4c2eb8f4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.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.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 long maxAge = -1;
+ private long maxIdleTime = -1;
+ 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;
+ }
+
+ public long getMaxAge() {
+ return maxAge;
+ }
+
+ public void setMaxAge(long maxAge) {
+ this.maxAge = maxAge;
+ }
+
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ public void setMaxIdleTime(long maxIdleTime) {
+ this.maxIdleTime = maxIdleTime;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
new file mode 100644
index 0000000000..ce4a0ef928
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java
@@ -0,0 +1,577 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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();
+ if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
new file mode 100644
index 0000000000..b951e17fd2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.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.introspect.impl;
+
+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.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+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.util.JavaXMLMapper;
+
+/**
+ * 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("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("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("Missing property name: " + parameter);
+ }
+ if ("".equals(name)) {
+ name = parameter.getName();
+ }
+
+ if (!getRequired(annotation)) {
+ throw new InvalidPropertyException("JCA_90014 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 abstract String getName(A annotation);
+ protected abstract boolean getRequired(A annotation);
+
+ protected abstract void initProperty(Property property, A annotation) throws IntrospectionException;
+
+ protected Property createProperty(String name, JavaElementImpl element) throws IntrospectionException {
+
+ Property property = assemblyFactory.createProperty();
+ property.setName(name);
+ Class<?> baseType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+ property.setXSDType(JavaXMLMapper.getXMLType(baseType));
+
+ Class<?> javaType = element.getType();
+ if (javaType.isArray() || Collection.class.isAssignableFrom(javaType)) {
+ property.setMany(true);
+ }
+ return property;
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
new file mode 100644
index 0000000000..68f0b46f2e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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("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 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
new file mode 100644
index 0000000000..25f31c5f12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.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.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("Destructor must not have argments", 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");
+ }
+ if (!Modifier.isPublic(method.getModifiers())) {
+ throw new IllegalDestructorException("Destructor must be a public method. Invalid annotation @Destroy found on "+method);
+ }
+ type.setDestroyMethod(method);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
new file mode 100644
index 0000000000..9ad7e8f7a9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 (!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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
new file mode 100644
index 0000000000..87a8031ea7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
@@ -0,0 +1,662 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.toPropertyName;
+
+import java.lang.annotation.Annotation;
+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.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+import org.oasisopen.sca.annotation.Callback;
+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);
+ }
+ }
+ Set<Method> methods = getAllUniquePublicProtectedMethods(clazz, false);
+ 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;
+ }
+ calcPropRefs(methods, services, type, clazz);
+ evaluateConstructor(type, clazz);
+ }
+
+ 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 <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 (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
+ // 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));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ } else {
+ type.getProperties().add(createProperty(name, param));
+ 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 (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
+ // Add the property name as others
+ others.add(toPropertyName(method.getName()));
+ continue;
+ }
+ Class<?> param = method.getParameterTypes()[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));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, param));
+ 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 (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class)) {
+ continue;
+ }
+ if (setters.contains(field.getName()) || others.contains(field.getName())) {
+ continue;
+ }
+ String name = field.getName();
+ Class<?> paramType = field.getType();
+ if (isReferenceType(paramType, field.getGenericType())) {
+ if (!type.getReferenceMembers().containsKey(name)) {
+ type.getReferences().add(createReference(name, paramType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(field));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, paramType));
+ 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 {
+ // no definition, heuristically determine constructor
+ Constructor[] constructors = clazz.getConstructors();
+ if (constructors.length == 0) {
+ throw new NoConstructorException("No public constructor for class");
+ } else if (constructors.length == 1) {
+ // Only one constructor, take it
+ constructor = constructors[0];
+ } else {
+ // FIXME multiple constructors, none yet done
+ Constructor<T> selected = null;
+ int sites = type.getPropertyMembers().size() + type.getReferenceMembers().size();
+ for (Constructor<T> ctor : constructors) {
+ if (ctor.getParameterTypes().length == 0) {
+ selected = ctor;
+ }
+ if (ctor.getParameterTypes().length == sites) {
+ // TODO finish
+ // selected = constructor;
+ // select constructor
+ // break;
+ }
+ }
+ if (selected == null) {
+ throw new NoConstructorException();
+ }
+ constructor = selected;
+ definition = type.getConstructors().get(selected);
+ type.setConstructor(definition);
+ // return;
+ }
+ 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 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.setClassifer(Reference.class);
+ type.getReferenceMembers().put(name, p);
+ } else {
+ type.getProperties().add(createProperty(name, p.getType()));
+ 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<?> paramType) {
+ org.apache.tuscany.sca.assembly.Property property = assemblyFactory.createProperty();
+ property.setName(name);
+ property.setXSDType(JavaXMLMapper.getXMLType(paramType));
+ return property;
+ }
+
+ private org.apache.tuscany.sca.assembly.Reference createReference(String name, Class<?> paramType)
+ throws IntrospectionException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ reference.setName(name);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+ try {
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ reference.setMultiplicity(Multiplicity.ZERO_ONE);
+ } catch (InvalidInterfaceException e1) {
+ throw new IntrospectionException(e1);
+ }
+
+ // FIXME: This part seems to have already been taken care above!!
+ try {
+ processCallback(paramType, reference);
+ } catch (InvalidServiceTypeException e) {
+ throw new IntrospectionException(e);
+ }
+ return reference;
+ }
+
+ 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.
+ */
+ 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()) {
+ Class<? extends Annotation> annotType = annotation.annotationType();
+ if (annotType.equals(Property.class) || annotType.equals(Reference.class)
+ || annotType.equals(Resource.class)) {
+ 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.equals(Property.class) || annotType.equals(Reference.class)
+ || annotType.equals(Resource.class)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
new file mode 100644
index 0000000000..8d67236fe2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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("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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
new file mode 100644
index 0000000000..79a0adac88
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(
+ "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(
+ "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(
+ "Method that is not an SCA reference cannot have policySet/intent annotations: " + method);
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
new file mode 100644
index 0000000000..d30ac074af
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
new file mode 100644
index 0000000000..30ed5dda44
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.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.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(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("JCA???? 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(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<?> 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);
+ service.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java
new file mode 100644
index 0000000000..3537dc97cf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
new file mode 100644
index 0000000000..efb4a37143
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.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.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+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;
+
+
+ public JavaImplementationProcessor(FactoryExtensionPoint modelFactories) {
+ this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
+ this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
+ this.javaFactory = modelFactories.getFactory(JavaImplementationFactory.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(),
+ "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);
+
+ 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 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..aa889448f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.java,model=org.apache.tuscany.sca.implementation.java.JavaImplementation
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
new file mode 100644
index 0000000000..2760b94e39
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
@@ -0,0 +1,33 @@
+# 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=200
+org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;ranking=190
+org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;ranking=180
+org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;ranking=170
+org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;ranking=160
+org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;ranking=150
+org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;ranking=140
+org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;ranking=130
+org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;ranking=120
+org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;ranking=110
+org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;ranking=100
+org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;ranking=90
+org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;ranking=80
+org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;ranking=70
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
new file mode 100644
index 0000000000..337a0b8458
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddService.java
new file mode 100644
index 0000000000..9c22177684
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..64298b6275
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..e0cf23dc17
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..9f64dc8bca
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideService.java
new file mode 100644
index 0000000000..9599c86292
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f5b8ff5be0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..7a3d06c15e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..d146d23153
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..21af91f392
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..ffe09c3dde
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java
new file mode 100644
index 0000000000..b82205863c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.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.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);
+ fail();
+ } catch (IllegalDestructorException e) {
+ // expected
+ }
+ }
+
+ @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);
+ fail();
+ } catch (IllegalDestructorException e) {
+ // expected
+ }
+ }
+
+ 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(){
+ }
+
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
new file mode 100644
index 0000000000..ede71a90dd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java
@@ -0,0 +1,583 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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 javax.xml.namespace.QName;
+
+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.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java
new file mode 100644
index 0000000000..d591123aef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
new file mode 100644
index 0000000000..635b491b06
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java
@@ -0,0 +1,241 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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);
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite
new file mode 100644
index 0000000000..f4182679bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml
new file mode 100644
index 0000000000..88a8e346c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+<!-- 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/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml
new file mode 100644
index 0000000000..60d63a3e5f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <!-- 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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..986e931927
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: org.apache.tuscany.sca.implementation.osgi.runtime
+Bundle-Version: 2.0.0
+Bundle-ActivationPolicy: lazy
+Bundle-Name: Apache Tuscany SCA OSGi Implementation Runtime
+Bundle-Vendor: The Apache Software Foundation
+Eclipse-LazyStart: true
+Bundle-Activator: org.apache.tuscany.sca.implementation.osgi.runtime.OSGiImplementationRuntimeActivator
+Bundle-Description: Apache Tuscany SCA OSGi Implementation
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+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
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/pom.xml
new file mode 100644
index 0000000000..f9203471f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java
new file mode 100644
index 0000000000..e54d2eee7b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.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.osgi.runtime;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+/**
+ * OSGi distribution provider for remote services
+ */
+public class OSGiDistributionProvider {
+ /**
+ * Registered by the distribution provider on one of its services to indicate the
+ * supported configuration types.
+ */
+ public static final String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported"; // String+
+
+ /**
+ * Registered by the distribution provider on one of its services to indicate the vocabulary
+ * of implemented intents.
+ */
+ public static final String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported"; // String+
+
+ /**
+ * Service Registration property for the name of the Distribution Provider
+ * product.
+ * <p>
+ * The value of this property is of type String.
+ */
+ static final String PRODUCT_NAME = "osgi.remote.distribution.product";
+
+ /**
+ * Service Registration property for the version of the Distribution
+ * Provider product.
+ * <p>
+ * The value of this property is of type String.
+ */
+ static final String PRODUCT_VERSION = "osgi.remote.distribution.product.version";
+
+ /**
+ * Service Registration property for the Distribution Provider product
+ * vendor name.
+ * <p>
+ * The value of this property is of type String.
+ */
+ static final String VENDOR_NAME = "osgi.remote.distribution.vendor";
+
+ private BundleContext bundleContext;
+
+ public OSGiDistributionProvider(BundleContext bundleContext) {
+ super();
+ this.bundleContext = bundleContext;
+ }
+
+ public Dictionary<String, Object> getProperties() {
+ Dictionary headers = bundleContext.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(REMOTE_CONFIGS_SUPPORTED, new String[] {"org.osgi.sca"});
+ // FIXME: We need to populate the list of intents from the SCA definitions
+ props.put(REMOTE_INTENTS_SUPPORTED, new String[] {});
+ return props;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
new file mode 100644
index 0000000000..9111a7d03c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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.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.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.RuntimeWire;
+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.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 (RuntimeWire wire : reference.getRuntimeWires()) {
+ final OSGiServiceFactory serviceFactory = new OSGiServiceFactory(javaInterface.getName(), wire);
+ 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;
+ }
+
+ public class OSGiServiceFactory implements ServiceFactory {
+ private RuntimeWire wire;
+ private String interfaceName;
+
+ /**
+ * @param interfaceName
+ * @param wire
+ */
+ public OSGiServiceFactory(String interfaceName, RuntimeWire wire) {
+ super();
+ this.interfaceName = interfaceName;
+ this.wire = wire;
+ }
+
+ public Object getService(Bundle bundle, ServiceRegistration registration) {
+ 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, wire);
+ return proxy;
+ }
+
+ public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
+ // Do we need to release the proxy?
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java
new file mode 100644
index 0000000000..a1de00d240
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.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.osgi.runtime;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * Bundle activator to receive the BundleContext
+ */
+public class OSGiImplementationRuntimeActivator implements BundleActivator {
+ private static BundleContext bundleContext;
+ private ServiceRegistration distributionProvider;
+
+ public void start(BundleContext context) throws Exception {
+ bundleContext = context;
+ OSGiDistributionProvider provider = new OSGiDistributionProvider(bundleContext);
+ distributionProvider =
+ bundleContext.registerService(OSGiDistributionProvider.class.getName(), provider, provider.getProperties());
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ if (distributionProvider != null) {
+ try {
+ distributionProvider.unregister();
+ } catch (IllegalStateException e) {
+ // The service has been unregistered, ignore it
+ }
+ }
+ bundleContext = null;
+ }
+
+ static BundleContext getBundleContext() {
+ return bundleContext;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..f531c2c4ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties
new file mode 100644
index 0000000000..2503be0b13
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/LICENSE
new file mode 100644
index 0000000000..6b0b1270ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/META-INF/MANIFEST.MF
new file mode 100755
index 0000000000..9956060457
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,36 @@
+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
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/pom.xml
new file mode 100644
index 0000000000..f89ab2c5b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/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-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
new file mode 100644
index 0000000000..20c7e8d60a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java
new file mode 100644
index 0000000000..d7296e24bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java
new file mode 100644
index 0000000000..ba5e5284be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java
new file mode 100644
index 0000000000..be39e4d3e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.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.osgi;
+
+import java.util.Collection;
+
+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);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java
new file mode 100644
index 0000000000..ebe4ef2dbc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.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.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";
+
+ /**
+ * The configuration types supported by this Distribution Provider.
+ *
+ * Services that are suitable for distribution list the configuration types
+ * that describe the configuration information for that service in the
+ * {@link #SERVICE_EXPORTED_CONFIGS} or {@link #SERVICE_IMPORTED_CONFIGS}
+ * property.
+ *
+ * A distribution provider must register a service that has this property
+ * and enumerate all configuration types that it supports.
+ *
+ * The type of this property <code>String+</code>
+ *
+ * @see #SERVICE_EXPORTED_CONFIGS
+ * @see #SERVICE_IMPORTED_CONFIGS
+ */
+ public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+ /**
+ * Service property that lists the intents supported by the distribution
+ * provider.
+ *
+ * Each distribution provider must register a service that has this property
+ * and enumerate all the supported intents, having any qualified intents
+ * expanded.
+ *
+ * The value of this property is of type <code>String+</code>.
+ *
+ * @see #SERVICE_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS_EXTRA
+ */
+ public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+ /**
+ * A list of configuration types that should be used to export the service.
+ *
+ * Configuration types can be <em>synonymous</em> or <em>alternatives</em>.
+ * In principle, a distribution provider should create an endpoint for each
+ * recognized configuration type, the deployer is responsible that synonyms
+ * do not clash.
+ *
+ * Each configuration type has an associated specification that describes
+ * how the configuration data for the exported service is represented in an
+ * OSGi framework.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+ /**
+ * A list of 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.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+ /**
+ * Extra intents configured in addition to the the intents specified in
+ * {@link #SERVICE_EXPORTED_INTENTS}.
+ *
+ * These intents are merged with the service.exported.intents and therefore
+ * have the same semantics. They are extra, so that the
+ * {@link #SERVICE_EXPORTED_INTENTS} can be set by the bundle developer and
+ * this property is then set by the administrator/deployer. Bundles should
+ * make this property configurable, for example through the Configuration
+ * Admin service.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+ /**
+ * Defines the interfaces under which this service can be exported.
+ *
+ * This list must be a subset of the types listed in the objectClass service
+ * property. The single value of an asterisk ('*' \u002A) indicates all
+ * interfaces in the registration's objectClass property (not classes). It
+ * is highly recommended to only export interfaces and not concrete classes
+ * due to the complexity of creating proxies for some type of classes.
+ *
+ * The value of this property is of type String+.
+ */
+ public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+ /**
+ * Must be set by a distribution provider to <code>true</code> when it
+ * registers the end-point proxy as an imported service. Can be used by a
+ * bundle to prevent it from getting an imported service.
+ *
+ * The value of this property is not defined, setting it is sufficient.
+ */
+ public final static String SERVICE_IMPORTED = "service.imported";
+ /**
+ * A list of intents that this service implements. This property has dual
+ * purpose. A bundle can use this service property to notify the
+ * distribution provider that these intents are already implemented by the
+ * exported service object. For an imported service, a distribution provider
+ * must use this property to convey the combined intents of the exporting
+ * service and the intents that the distribution providers add. To export a
+ * service, a distribution provider must recognize all these intents and
+ * expand any qualified intents.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_INTENTS = "service.intents";
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_FRAMEWORK_UUID = "service.remote.framework.id";
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_ID = "service.remote.id";
+ /**
+ * The property key for the endpoint URI. This is a unique id for an
+ * endpoint following the URI syntax. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_URI = "service.remote.uri";
+ /**
+ * The configuration type used to import this services, as described in
+ * {@link #SERVICE_EXPORTED_CONFIGS}. 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. Configuration types in this property
+ * must be synonymous.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java
new file mode 100644
index 0000000000..a54324b027
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java
new file mode 100644
index 0000000000..119d7ed657
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java
new file mode 100644
index 0000000000..35866938d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.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;
+
+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/sd/v1.0.0";
+ QName SERVICE_DESCRIPTIONS_QNAME = new QName(OSGI_SD_NS, "service-descriptions");
+ QName SERVICE_DESCRIPTION_QNAME = new QName(OSGI_SD_NS, "service-description");
+ String REMOTE_SERVICE_HEADER = "Remote-Service";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java
new file mode 100644
index 0000000000..535bef2b6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
new file mode 100644
index 0000000000..2978e8e823
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.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.implementation.osgi.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
new file mode 100644
index 0000000000..51e1e69b5d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.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.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);
+ }
+ }
+
+ private boolean areEqual(Object obj1, Object obj2) {
+ if (obj1 == obj2)
+ return true;
+ if (obj1 == null || obj2 == null)
+ return false;
+ return obj1.equals(obj2);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+
+ if (!(obj instanceof OSGiImplementationImpl))
+ return super.equals(obj);
+ OSGiImplementationImpl impl = (OSGiImplementationImpl)obj;
+ if (!areEqual(bundleSymbolicName, impl.bundleSymbolicName))
+ return false;
+ if (!areEqual(bundleVersion, impl.bundleVersion))
+ return false;
+ return super.equals(obj);
+ }
+
+ public void setBundleSymbolicName(String bundleSymbolicName) {
+ this.bundleSymbolicName = bundleSymbolicName;
+ }
+
+ public void setBundleVersion(String bundleVersion) {
+ this.bundleVersion = bundleVersion;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java
new file mode 100644
index 0000000000..b990cf5980
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.implementation.osgi.ServiceDescription;
+
+/**
+ * The OSGi RFC 119 description of a remote OSGi service
+ */
+public class ServiceDescriptionImpl implements ServiceDescription {
+ private List<String> interfaces = new ArrayList<String>();
+ private Map<String, Object> properties = new HashMap<String, Object>();
+
+ protected ServiceDescriptionImpl() {
+ super();
+ }
+
+ public List<String> getInterfaces() {
+ return interfaces;
+ }
+
+ public Map<String, Object> getProperties() {
+ return properties;
+ }
+
+ public String toString() {
+ return "service-description: interfaces=" + interfaces + " properties=" + properties;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java
new file mode 100644
index 0000000000..84734b88db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.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.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 {
+ writer.writeStartElement(PROPERTY_QNAME.getNamespaceURI(), PROPERTY_QNAME.getLocalPart());
+ writer.writeAttribute(NAME, model.getName());
+ writer.writeAttribute(TYPE, model.getType());
+ writer.writeCharacters(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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java
new file mode 100644
index 0000000000..9c529eecfc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.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.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/200903"
+ 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 (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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java
new file mode 100644
index 0000000000..fc6e44d8d6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.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.implementation.osgi.xml;
+
+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;
+
+/*
+<?xml version="1.0" encoding="UTF-8"?>
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0">
+ <service-description>
+ <provide interface="com.iona.soa.pojo.hello.HelloService"/>
+ <property name="service.intents">SOAP HTTP</property>
+ <property name="osgi.remote.configuration.type">pojo</property>
+ <property name="osgi.remote.configuration.pojo.address">
+ http://localhost:9000/hello
+ </property>
+ </service-description>
+ <service-description>
+ <provide interface="com.iona.soa.pojo.hello.GreeterService"/>
+ <property name="service.intents">SOAP HTTP</property>
+ <property name="osgi.remote.configuration.type">pojo</property>
+ <property name="osgi.remote.configuration.pojo.address">
+ http://localhost:9005/greeter
+ </property>
+ </service-description>
+</service-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 = factory.createServiceDescriptions();
+ ServiceDescription sd = null;
+ while (true) {
+ switch (event) {
+ case XMLStreamConstants.START_ELEMENT:
+ QName name = reader.getName();
+ if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
+ sd = factory.createServiceDescription();
+ sds.add(sd);
+ } else if ("provide".equals(name.getLocalPart())) {
+ String interfaceName = reader.getAttributeValue(null, "interface");
+ if (interfaceName != null) {
+ sd.getInterfaces().add(interfaceName);
+ }
+ } 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);
+ }
+ if (propName.endsWith(".intents")) {
+ prop = toQNames(reader, propValue);
+ }
+ sd.getProperties().put(propName, prop);
+ } else {
+ name = reader.getName();
+ if (!ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ Object ext = processor.read(reader, context);
+ if (sd != null) {
+ sd.getProperties().put(name.toString(), ext);
+ }
+ }
+ }
+ break;
+ case XMLStreamConstants.END_ELEMENT:
+ name = reader.getName();
+ if (ServiceDescriptions.SERVICE_DESCRIPTION_QNAME.equals(name)) {
+ // Reset the sd
+ sd = null;
+ }
+ if (ServiceDescriptions.SERVICE_DESCRIPTIONS_QNAME.equals(name)) {
+ return sds;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return sds;
+ }
+ }
+ }
+
+ /**
+ * 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 {
+ // TODO: To be implemented
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml
new file mode 100644
index 0000000000..f531c2c4ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..c3af0902a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/sd/v1.0.0#service-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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties
new file mode 100644
index 0000000000..a406ea21c3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..656b78b717
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java
new file mode 100644
index 0000000000..6b59b498fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.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.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.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.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.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);
+ }
+
+ @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);
+ }
+
+ @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();
+ Assert.assertTrue(sw.toString().contains("bundleSymbolicName=\"osgi.test\" bundleVersion=\"1.0.0\""));
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java
new file mode 100644
index 0000000000..1b28373f5b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.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.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\"?>"
+ + "<service-descriptions xmlns=\"http://www.osgi.org/xmlns/sd/v1.0.0\" "
+ + "xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\">"
+ + "<service-description>"
+ + "<provide interface=\"calculator.operations.AddService\"/>"
+ + "<property name=\"service.intents\">sca:SOAP sca:HTTP</property>"
+ + "<property name=\"osgi.remote.configuration.type\">sca</property>"
+ + "<property name=\"osgi.remote.configuration.sca.componentType\">"
+ + "OSGI-INF/sca/bundle.componentType"
+ + "</property>"
+ + "<property name=\"osgi.remote.configuration.sca.reference\">"
+ + "addService"
+ + "</property>"
+ + "</service-description>"
+ + "<service-description>"
+ + "<provide interface=\"calculator.operations.SubtractService\"/>"
+ + "<property name=\"service.intents\">sca:SOAP sca:HTTP</property>"
+ + "<property name=\"osgi.remote.configuration.type\">sca</property>"
+ + "<property name=\"osgi.remote.configuration.sca.componentType\">"
+ + "OSGI-INF/sca/bundle.componentType"
+ + "</property>"
+ + "<property name=\"osgi.remote.configuration.sca.reference\">"
+ + "subtractService"
+ + "</property>"
+ + "</service-description>"
+ + "</service-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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..3e537df732
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..bc9e4f6aaf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/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/200903"
+ 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 -->
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/osgitest.composite b/tags/java/sca/2.0-M4-RC2/modules/implementation-osgi/src/test/resources/osgitest.composite
new file mode 100644
index 0000000000..8c59703724
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..801258d85c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/META-INF/MANIFEST.MF
@@ -0,0 +1,26 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Spring Implementation Runtime Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397170750
+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",
+ org.springframework.beans;version="2.5.5",
+ org.springframework.beans.factory;version="2.5.5",
+ org.springframework.beans.factory.annotation;version="2.5.5",
+ org.springframework.beans.factory.config;version="2.5.5",
+ org.springframework.beans.factory.support;version="2.5.5",
+ org.springframework.beans.factory.xml;version="2.5.5",
+ org.springframework.context;version="2.5.5",
+ org.springframework.context.support;version="2.5.5",
+ org.springframework.core.io;version="2.5.5",
+ org.springframework.util;version="2.5.5"
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/README b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/pom.xml
new file mode 100644
index 0000000000..f2f27fd841
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring-sca</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Runtime Model</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-M4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Spring dependencies... -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>2.5.5</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java
new file mode 100644
index 0000000000..75e00007f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java
new file mode 100644
index 0000000000..f136e45b87
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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() {
+ init();
+ }
+
+ public final void init() {
+ registerBeanDefinitionParser("reference", new ScaReferenceBeanDefinitionParser());
+ registerBeanDefinitionParser("service", new ScaServiceBeanDefinitionParser());
+ registerBeanDefinitionParser("property", new ScaPropertyBeanDefinitionParser());
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
new file mode 100644
index 0000000000..5b1064d8d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java
@@ -0,0 +1,35 @@
+/*
+ * 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.config.BeanDefinition;
+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) {
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
new file mode 100644
index 0000000000..fac02760c9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java
@@ -0,0 +1,36 @@
+/*
+ * 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.config.BeanDefinition;
+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) {
+ // do nothing, this is handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
new file mode 100644
index 0000000000..3020dca8bc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java
@@ -0,0 +1,36 @@
+/*
+ * 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.config.BeanDefinition;
+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) {
+ // do nothing, handled by Tuscany
+ return null;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
new file mode 100644
index 0000000000..7613f8166d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java
new file mode 100644
index 0000000000..c72ccd6636
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
new file mode 100644
index 0000000000..7eb63678f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java
new file mode 100644
index 0000000000..477582b1d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
new file mode 100644
index 0000000000..f800654c34
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.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.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java
new file mode 100644
index 0000000000..ea8f560ae1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
new file mode 100644
index 0000000000..dd43d63d97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.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.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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java
new file mode 100644
index 0000000000..c1aaf1570f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java
@@ -0,0 +1,29 @@
+package org.apache.tuscany.sca.implementation.spring.runtime.context;
+
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+
+public class SCAGenericApplicationContext extends GenericApplicationContext {
+
+ ClassLoader classloader = null;
+
+ 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);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
new file mode 100644
index 0000000000..5ea1c2fd9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.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.spring.runtime.context;
+
+import java.io.IOException;
+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$
+ */
+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 {
+ return implementation.getBean(name, requiredType);
+ } // end method getBean( String, Class )
+
+ public Object getBean(String name, Object[] args) throws BeansException {
+ return getBean(name, ((Class)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 ApplicationContext getParent() {
+ return null;
+ }
+
+ 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();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
new file mode 100644
index 0000000000..77681b600f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.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.spring.runtime.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.ComponentStub;
+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.PropertyValueStub;
+import org.apache.tuscany.sca.implementation.spring.processor.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.XmlBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+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 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) {
+
+ XmlBeanFactory beanFactory = null;
+ AbstractApplicationContext appContext = null;
+
+ if (resources.size() > 1) {
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+ }
+
+ // use the generic application context as default
+ beanFactory = new XmlBeanFactory(new UrlResource(resources.get(0)));
+ beanFactory.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(beanFactory);
+ appContext = new SCAGenericApplicationContext(beanFactory,
+ scaParentContext,
+ implementation.getClassLoader());
+ return appContext;
+ }
+
+ 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);
+ }
+
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
new file mode 100644
index 0000000000..af39869522
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.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.runtime.context;
+
+import java.lang.reflect.Method;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+/**
+ * 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;
+
+ 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");
+ } 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);
+ }
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.handlers b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.handlers
new file mode 100644
index 0000000000..6d29e21024
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.schemas b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/META-INF/spring.schemas
new file mode 100644
index 0000000000..249cc21c13
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/org/springframework/sca/xml/spring-sca.xsd b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/src/main/resources/org/springframework/sca/xml/spring-sca.xsd
new file mode 100644
index 0000000000..dfa0b931f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring-sca/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1cb55b33db
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/META-INF/MANIFEST.MF
@@ -0,0 +1,55 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Spring Implementation Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397170750
+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.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";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.assembly.impl,
+ org.apache.tuscany.sca.interfacedef,
+ javax.xml.namespace",
+ org.apache.tuscany.sca.implementation.spring.introspect;version="2.0.0";
+ uses:="org.apache.tuscany.sca.assembly,
+ org.apache.tuscany.sca.implementation.java.introspect,
+ org.apache.tuscany.sca.implementation.spring,
+ org.apache.tuscany.sca.implementation.java,
+ org.apache.tuscany.sca.policy,
+ org.apache.tuscany.sca.interfacedef.java"
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/README b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/README
new file mode 100644
index 0000000000..e1b1f98fe0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/pom.xml
new file mode 100644
index 0000000000..3a32659148
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-implementation-spring</artifactId>
+ <name>Apache Tuscany SCA Spring Implementation Model</name>
+
+ <dependencies>
+
+ <!-- **************************************** -->
+ <!-- * * -->
+ <!-- * DONT ADD ANY SPRING DEPENDENCIES!!! * -->
+ <!-- * * -->
+ <!-- * See the README for details why not * -->
+ <!-- * * -->
+ <!-- * * -->
+ <!-- **************************************** -->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
new file mode 100644
index 0000000000..f64c5f9476
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.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.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(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;
+ }
+
+} // end class SpringBeanElement
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
new file mode 100644
index 0000000000..9ae1273592
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/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;
+
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
new file mode 100644
index 0000000000..8081fb4911
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.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.implementation.spring;
+
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.List;
+
+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;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+
+/**
+ * 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 Hashtable<String, SpringBeanElement> serviceMap;
+ // Mapping of property names to Java class
+ private Hashtable<String, Class<?>> propertyMap;
+ // List of unresolved bean property references
+ private Hashtable<String, Reference> unresolvedBeanRef;
+ private ClassLoader classLoader;
+
+ public SpringImplementation() {
+ super(TYPE);
+ this.location = null;
+ this.resource = null;
+ setUnresolved(true);
+ serviceMap = new Hashtable<String, SpringBeanElement>();
+ propertyMap = new Hashtable<String, Class<?>>();
+ unresolvedBeanRef = new Hashtable<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) {
+ if (!(component instanceof RuntimeComponent))
+ return;
+
+ RuntimeComponent rtc = (RuntimeComponent) component;
+
+ for (Reference reference : rtc.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 : rtc.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;
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java
new file mode 100644
index 0000000000..1a246fa03a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
new file mode 100644
index 0000000000..caae72fa90
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
new file mode 100644
index 0000000000..37b8ef37a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.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.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(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);
+ }
+
+} // end class SpringPropertyElement
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
new file mode 100644
index 0000000000..b192580a78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.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.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(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;
+ }
+
+} // end class SpringPropertyElement
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
new file mode 100644
index 0000000000..bc010229ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.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;
+
+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(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;
+ }
+
+} // end class SpringSCAReferenceElement
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
new file mode 100644
index 0000000000..dbddc00b33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.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;
+
+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(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;
+ }
+
+} // end class SpringSCAServiceElement
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
new file mode 100644
index 0000000000..3aa257686d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.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.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;
+
+/**
+ * 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();
+
+ 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
+
+ /* List<Service> services = javaImplementation.getServices();
+ for (Service service : services) {
+ String name = service.getName();
+ System.out.println("Spring Bean: found service with name: " + name);
+ } // end for */
+
+ return javaImplementation;
+
+ } // end method introspectBean
+
+} // end class SpringBeanIntrospector
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
new file mode 100644
index 0000000000..3a8eec99fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
@@ -0,0 +1,660 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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 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.getPrivateFields;
+import static org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper.toPropertyName;
+
+import java.lang.annotation.Annotation;
+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.implementation.java.introspect.impl.AmbiguousConstructorException;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.InvalidServiceTypeException;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.NoConstructorException;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.Resource;
+import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
+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.interfacedef.util.JavaXMLMapper;
+import org.oasisopen.sca.annotation.Callback;
+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 SpringBeanPojoProcessor extends BaseJavaClassVisitor {
+ private List<SpringConstructorArgElement> conArgs;
+
+ public SpringBeanPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory, List<SpringConstructorArgElement> conArgs) {
+ super(assemblyFactory);
+ this.javaInterfaceFactory = javaFactory;
+ this.conArgs = conArgs;
+ }
+
+ public SpringBeanPojoProcessor(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);
+ }
+ }
+ Set<Method> methods = getAllUniquePublicProtectedMethods(clazz, false);
+ 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;
+ }
+ calcPropRefs(methods, services, type, clazz);
+ evaluateConstructor(type, clazz);
+ }
+
+ 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 boolean isPublicSetter(Method method) {
+ return method.getParameterTypes().length == 1 && Modifier.isPublic(method.getModifiers())
+ && method.getName().startsWith("set")
+ && method.getReturnType() == void.class;
+ }
+
+ private boolean isProtectedSetter(Method method) {
+ return method.getParameterTypes().length == 1 && Modifier.isProtected(method.getModifiers())
+ && method.getName().startsWith("set")
+ && method.getReturnType() == void.class;
+ }
+
+ 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 (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
+ // 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));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ } else {
+ type.getProperties().add(createProperty(name, param));
+ 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 (method.isAnnotationPresent(Callback.class) || method.isAnnotationPresent(Context.class)) {
+ // Add the property name as others
+ others.add(toPropertyName(method.getName()));
+ continue;
+ }
+ Class<?> param = method.getParameterTypes()[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));
+ type.getReferenceMembers().put(name, new JavaElementImpl(method, 0));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, param));
+ 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 (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class)) {
+ continue;
+ }
+ if (setters.contains(field.getName()) || others.contains(field.getName())) {
+ continue;
+ }
+ String name = field.getName();
+ Class<?> paramType = field.getType();
+ if (isReferenceType(paramType, field.getGenericType())) {
+ if (!type.getReferenceMembers().containsKey(name)) {
+ type.getReferences().add(createReference(name, paramType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(field));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, paramType));
+ type.getPropertyMembers().put(name, new JavaElementImpl(field));
+ }
+ }
+ }
+
+ // Private fields unless there is a public or protected
+ // setter method for the same name
+ Set<Field> privateFields = getPrivateFields(clazz);
+ for (Field field : privateFields) {
+ if (field.isAnnotationPresent(Callback.class) || field.isAnnotationPresent(Context.class)) {
+ continue;
+ }
+ if (setters.contains(field.getName()) || others.contains(field.getName())) {
+ continue;
+ }
+ String name = field.getName();
+ Class<?> paramType = field.getType();
+ if (isReferenceType(paramType, field.getGenericType())) {
+ if (!type.getReferenceMembers().containsKey(name)) {
+ type.getReferences().add(createReference(name, paramType));
+ type.getReferenceMembers().put(name, new JavaElementImpl(field));
+ }
+ } else {
+ if (!type.getPropertyMembers().containsKey(name)) {
+ type.getProperties().add(createProperty(name, paramType));
+ 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();
+ Map<String, JavaElementImpl> props = type.getPropertyMembers();
+ Map<String, JavaElementImpl> refs = type.getReferenceMembers();
+ 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 {
+ // no definition, heuristically determine constructor
+ Constructor[] constructors = clazz.getConstructors();
+ if (constructors.length == 0) {
+ throw new NoConstructorException("No public constructor for class");
+ } else if (constructors.length == 1) {
+ // Only one constructor, take it
+ constructor = constructors[0];
+ } else {
+ // multiple constructors scenario
+ Constructor<T> selected = null;
+ for (Constructor<T> ctor : constructors) {
+ if (ctor.getParameterTypes().length == 0) {
+ selected = ctor;
+ } else if (ctor.getParameterTypes().length == conArgs.size()) {
+ // we will find a constructor which has atleast one
+ // reference or property as its parameter types.
+ Class<?>[] parametersTypes = ctor.getParameterTypes();
+ for (Class<?> pType: parametersTypes) {
+ for (JavaElementImpl property : props.values()) {
+ if (pType.equals(property.getType()))
+ selected = ctor;
+ }
+ for (JavaElementImpl reference : refs.values()) {
+ if (pType.equals(reference.getType()))
+ selected = ctor;
+ }
+ }
+ }
+ }
+ if (selected == null) {
+ throw new NoConstructorException();
+ }
+ constructor = selected;
+ }
+ definition = type.getConstructors().get(constructor);
+ type.setConstructor(definition);
+ }
+
+ JavaParameterImpl[] parameters = definition.getParameters();
+ if (parameters.length == 0) {
+ return;
+ }
+
+ 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 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.setClassifer(Reference.class);
+ type.getReferenceMembers().put(name, p);
+ } else {
+ type.getProperties().add(createProperty(name, p.getType()));
+ p.setClassifer(Property.class);
+ type.getPropertyMembers().put(name, p);
+ }
+ p.setName(name);
+ }
+ }
+
+ private static boolean areUnique(Class[] collection) {
+ Set<Class> set = new HashSet<Class>(Arrays.asList(collection));
+ return set.size() == collection.length;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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.
+ */
+ private 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
+ */
+ private 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 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;
+ }
+
+ /**
+ * 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<?> paramType) {
+ org.apache.tuscany.sca.assembly.Property property = assemblyFactory.createProperty();
+ property.setName(name);
+ property.setXSDType(JavaXMLMapper.getXMLType(paramType));
+ return property;
+ }
+
+ private boolean isAnnotated(JavaParameterImpl parameter) {
+ for (Annotation annotation : parameter.getAnnotations()) {
+ Class<? extends Annotation> annotType = annotation.annotationType();
+ if (annotType.equals(Property.class) || annotType.equals(Reference.class)
+ || annotType.equals(Resource.class)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public 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;
+ }
+
+ public org.apache.tuscany.sca.assembly.Reference createReference(String name, Class<?> paramType)
+ throws IntrospectionException {
+ org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
+ reference.setName(name);
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
+ reference.setInterfaceContract(interfaceContract);
+ try {
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
+ reference.getInterfaceContract().setInterface(callInterface);
+ if (callInterface.getCallbackClass() != null) {
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+ }
+ reference.setMultiplicity(Multiplicity.ZERO_ONE);
+ } catch (InvalidInterfaceException e1) {
+ throw new IntrospectionException(e1);
+ }
+
+ // FIXME: This part seems to have already been taken care above!!
+ try {
+ processCallback(paramType, reference);
+ } catch (InvalidServiceTypeException e) {
+ throw new IntrospectionException(e);
+ }
+ return reference;
+ }
+
+ public 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;
+ }
+
+ public 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);
+ }
+ }
+
+ public boolean injectionAnnotationsPresent(Annotation[][] annots) {
+ for (Annotation[] annotations : annots) {
+ for (Annotation annotation : annotations) {
+ Class<? extends Annotation> annotType = annotation.annotationType();
+ if (annotType.equals(Property.class) || annotType.equals(Reference.class)
+ || annotType.equals(Resource.class)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
new file mode 100644
index 0000000000..bd3134c5f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -0,0 +1,1153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, 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 static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+
+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.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+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.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.assembly.xml.PolicySubjectProcessor;
+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.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.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.SpringImplementationConstants;
+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.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.PolicyFactory;
+
+/**
+ * Introspects a Spring XML application-context configuration file to create <implementation-spring../>
+ * component type information.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SpringXMLComponentTypeLoader {
+ private ExtensionPointRegistry registry;
+ private XMLInputFactory xmlInputFactory;
+ private ContributionFactory contributionFactory;
+ private AssemblyFactory assemblyFactory;
+ private JavaInterfaceFactory javaFactory;
+ private PolicyFactory policyFactory;
+ private PolicySubjectProcessor policyProcessor;
+ private Monitor monitor;
+ private SpringBeanIntrospector beanIntrospector;
+
+ public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry,
+ Monitor monitor) {
+ super();
+ this.registry = registry;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ this.contributionFactory = factories.getFactory(ContributionFactory.class);
+ this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
+ this.monitor = monitor;
+ }
+
+ /**
+ * 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(), "impl-spring-validation-messages", Severity.ERROR, model, message, ex);
+ 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(), "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 {
+ XMLStreamReader reader;
+ 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());
+
+ for (URL contextResource : contextResources) {
+ List<SpringBeanElement> appCxtBeans = new ArrayList<SpringBeanElement>();
+ List<SpringSCAServiceElement> appCxtServices = new ArrayList<SpringSCAServiceElement>();
+ List<SpringSCAReferenceElement> appCxtReferences = new ArrayList<SpringSCAReferenceElement>();
+ List<SpringSCAPropertyElement> appCxtProperties = new ArrayList<SpringSCAPropertyElement>();
+ reader = xmlInputFactory.createXMLStreamReader(contextResource.openStream());
+ // Read the beans, services, references and properties for individual application context
+ readContextDefinition(resolver, reader, contextPath, appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties, context);
+ // Validate the beans from individual application context for uniqueness
+ validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties);
+ // Add all the validated beans to the generic list
+ beans.addAll(appCxtBeans);
+ services.addAll(appCxtServices);
+ references.addAll(appCxtReferences);
+ scaproperties.addAll(appCxtProperties);
+ reader.close();
+ }
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ } catch (XMLStreamException 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 artifact = contributionFactory.createArtifact();
+ artifact.setUnresolved(true);
+ artifact.setURI(contextPath);
+ 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;
+ }
+
+ /**
+ * Method which returns the XMLStreamReader for the Spring application-context.xml file
+ * specified in the location attribute
+ */
+ private XMLStreamReader getApplicationContextReader(ModelResolver resolver, String location, ProcessorContext context) throws ContributionReadException {
+
+ try {
+ URL resource = getApplicationContextResource(resolveLocation(resolver, location, context)).get(0);
+ XMLStreamReader reader =
+ xmlInputFactory.createXMLStreamReader(resource.openStream());
+ return reader;
+ } catch (IOException e) {
+ throw new ContributionReadException(e);
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ /**
+ * Method which reads the spring context definitions from Spring application-context.xml
+ * file and identifies the defined beans, properties, services and references
+ * @param context
+ */
+ private void readContextDefinition(ModelResolver resolver,
+ XMLStreamReader reader,
+ String contextPath,
+ List<SpringBeanElement> beans,
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties, ProcessorContext context) throws ContributionReadException {
+
+ SpringBeanElement bean = null;
+
+ try {
+ boolean completed = false;
+ while (!completed) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ //System.out.println("Spring TypeLoader - found element with name: " + qname.toString());
+ if (SpringImplementationConstants.IMPORT_ELEMENT.equals(qname)) {
+ //FIXME - put the sequence of code below which gets the ireader into a subsidiary method
+ String location = reader.getAttributeValue(null, "resource");
+ if (location != null) {
+ // FIXME - need to find a right way of generating this path
+ String resourcePath = contextPath.substring(0, contextPath.lastIndexOf("/")+1) + location;
+ XMLStreamReader ireader = getApplicationContextReader(resolver, resourcePath, context);
+ // Read the context definition for the identified imported resource
+ readContextDefinition(resolver, ireader, contextPath, beans, services, references, scaproperties, context);
+ }
+ } else if (SpringImplementationConstants.SCA_SERVICE_ELEMENT.equals(qname)) {
+ // The value of the @name attribute of an <sca:service/> subelement of a <beans/>
+ // element MUST be unique amongst the <sca:service/> subelements of the <beans/> element.
+ if (!services.isEmpty() && (services.contains(reader.getAttributeValue(null, "name"))))
+ error("ScaServiceNameNotUnique", resolver);
+
+ SpringSCAServiceElement service =
+ new SpringSCAServiceElement(reader.getAttributeValue(null, "name"),
+ reader.getAttributeValue(null, "target"));
+ if (reader.getAttributeValue(null, "type") != null)
+ service.setType(reader.getAttributeValue(null, "type"));
+ policyProcessor.readPolicies(service, reader);
+ services.add(service);
+ } else if (SpringImplementationConstants.SCA_REFERENCE_ELEMENT.equals(qname)) {
+ // 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:reference/> subelements,
+ // of the <beans/> element.
+ if (!references.isEmpty() && (references.contains(reader.getAttributeValue(null, "name"))))
+ error("ScaReferenceNameNotUnique", resolver);
+
+ SpringSCAReferenceElement reference =
+ new SpringSCAReferenceElement(reader.getAttributeValue(null, "name"),
+ reader.getAttributeValue(null, "type"));
+ if (reader.getAttributeValue(null, "default") != null)
+ reference.setDefaultBean(reader.getAttributeValue(null, "default"));
+ policyProcessor.readPolicies(reference, reader);
+ references.add(reference);
+ } else if (SpringImplementationConstants.SCA_PROPERTY_ELEMENT.equals(qname)) {
+ // 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:property/> subelements,
+ // of the <beans/> element.
+ if (!scaproperties.isEmpty() && (scaproperties.contains(reader.getAttributeValue(null, "name"))))
+ error("ScaPropertyNameNotUnique", resolver);
+
+ SpringSCAPropertyElement scaproperty =
+ new SpringSCAPropertyElement(reader.getAttributeValue(null, "name"), reader
+ .getAttributeValue(null, "type"));
+ scaproperties.add(scaproperty);
+ } else if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
+ bean = new SpringBeanElement(reader.getAttributeValue(null, "id"),
+ reader.getAttributeValue(null, "class"));
+ if (reader.getAttributeValue(null, "abstract") != null)
+ if (reader.getAttributeValue(null, "abstract").equals("true"))
+ bean.setAbstractBean(true);
+ if (reader.getAttributeValue(null, "parent") != null)
+ if (!reader.getAttributeValue(null, "parent").equals(""))
+ bean.setParentAttribute(true);
+ if (reader.getAttributeValue(null, "factory-bean") != null)
+ if (!reader.getAttributeValue(null, "factory-bean").equals(""))
+ bean.setFactoryBeanAttribute(true);
+ if (reader.getAttributeValue(null, "factory-method") != null)
+ if (!reader.getAttributeValue(null, "factory-method").equals(""))
+ bean.setFactoryMethodAttribute(true);
+ // Set the first name as bean name, when the @id attribute is absent.
+ if (reader.getAttributeValue(null, "id") == null) {
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ bean.setId(names[0]);
+ }
+ }
+ beans.add(bean);
+ // Read the <bean> element and its child elements
+ readBeanDefinition(reader, bean, beans);
+ } // end if
+ break;
+ case END_ELEMENT:
+ if (SpringImplementationConstants.BEANS_ELEMENT.equals(reader.getName())) {
+ //System.out.println("Spring TypeLoader - finished read of context file");
+ completed = true;
+ break;
+ } // end if
+ } // end switch
+ } // end while
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+
+ /**
+ * Method which reads the bean definitions from Spring application-context.xml file and identifies
+ * the defined beans, properties, services and references
+ */
+ private void readBeanDefinition(XMLStreamReader reader,
+ SpringBeanElement bean,
+ List<SpringBeanElement> beans) throws ContributionReadException {
+
+ SpringBeanElement innerbean = null;
+ SpringPropertyElement property = null;
+ SpringConstructorArgElement constructorArg = null;
+
+ try {
+ boolean completed = false;
+ while (!completed) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
+ innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
+ .getAttributeValue(null, "class"));
+ // Set the first name as bean name, when the @id attribute is absent.
+ if (reader.getAttributeValue(null, "id") == null) {
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ innerbean.setId(names[0]);
+ }
+ }
+ innerbean.setInnerBean(true);
+ beans.add(innerbean);
+ readBeanDefinition(reader, innerbean, beans);
+ } else if (SpringImplementationConstants.PROPERTY_ELEMENT.equals(qname)) {
+ property = new SpringPropertyElement(reader.getAttributeValue(null, "name"));
+ if (reader.getAttributeValue(null, "ref") != null)
+ property.addRef(reader.getAttributeValue(null, "ref"));
+ bean.addProperty(property);
+ } else if (SpringImplementationConstants.CONSTRUCTORARG_ELEMENT.equals(qname)) {
+ constructorArg = new SpringConstructorArgElement(reader.getAttributeValue(null, "type"));
+ if (reader.getAttributeValue(null, "ref") != null)
+ constructorArg.addRef(reader.getAttributeValue(null, "ref"));
+ if (reader.getAttributeValue(null, "index") != null)
+ constructorArg.setIndex((new Integer(reader.getAttributeValue(null, "index"))).intValue());
+ if (reader.getAttributeValue(null, "value") != null)
+ constructorArg.addValue(reader.getAttributeValue(null, "value"));
+ bean.addCustructorArgs(constructorArg);
+ } else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
+ String ref = reader.getAttributeValue(null, "bean");
+ // Check if the parent element is a property
+ if (property != null) property.addRef(ref);
+ // Check if the parent element is a constructor-arg
+ if (constructorArg != null) constructorArg.addRef(ref);
+ } else if (SpringImplementationConstants.VALUE_ELEMENT.equals(qname)) {
+ String value = reader.getElementText();
+ // Check if the parent element is a constructor-arg
+ if (constructorArg != null) constructorArg.addValue(value);
+ } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) ||
+ SpringImplementationConstants.SET_ELEMENT.equals(qname) ||
+ SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
+ if (property != null)
+ readCollections(reader, bean, beans, property, null);
+ if (constructorArg != null)
+ readCollections(reader, bean, beans, null, constructorArg);
+ } // end if
+ break;
+ case END_ELEMENT:
+ if (SpringImplementationConstants.BEAN_ELEMENT.equals(reader.getName())) {
+ completed = true;
+ break;
+ } else if (SpringImplementationConstants.PROPERTY_ELEMENT.equals(reader.getName())) {
+ property = null;
+ } else if (SpringImplementationConstants.CONSTRUCTORARG_ELEMENT.equals(reader.getName())) {
+ constructorArg = null;
+ } // end if
+ } // end switch
+ } // end while
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+
+ /**
+ * Method which reads the collection elements from Spring application-context.xml file and identifies
+ * the defined beans, list, maps and sets
+ */
+ private void readCollections(XMLStreamReader reader,
+ SpringBeanElement bean,
+ List<SpringBeanElement> beans,
+ SpringPropertyElement property,
+ SpringConstructorArgElement constructorArg) throws ContributionReadException {
+
+ SpringBeanElement innerbean = null;
+
+ try {
+ boolean completed = false;
+ while (!completed) {
+ switch (reader.next()) {
+ case START_ELEMENT:
+ QName qname = reader.getName();
+ if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
+ innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
+ .getAttributeValue(null, "class"));
+ // Set the first name as bean name, when the @id attribute is absent.
+ if (reader.getAttributeValue(null, "id") == null)
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ innerbean.setId(names[0]);
+ }
+ innerbean.setInnerBean(true);
+ beans.add(innerbean);
+ readBeanDefinition(reader, innerbean, beans);
+ } else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
+ String ref = reader.getAttributeValue(null, "bean");
+ if (property != null) property.addRef(ref);
+ if (constructorArg != null) constructorArg.addRef(ref);
+ } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) ||
+ SpringImplementationConstants.SET_ELEMENT.equals(qname) ||
+ SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
+ if (property != null)
+ readCollections(reader, innerbean, beans, property, null);
+ if (constructorArg != null)
+ readCollections(reader, innerbean, beans, null, constructorArg);
+ } else if (SpringImplementationConstants.ENTRY_ELEMENT.equals(qname)) {
+ String keyRef = reader.getAttributeValue(null, "key-ref");
+ String valueRef = reader.getAttributeValue(null, "value-ref");
+ if (property != null) {property.addRef(keyRef); property.addRef(valueRef);}
+ if (constructorArg != null) {constructorArg.addRef(keyRef); constructorArg.addRef(valueRef);}
+ } // end if
+ break;
+ case END_ELEMENT:
+ if (SpringImplementationConstants.LIST_ELEMENT.equals(reader.getName())) {
+ completed = true;
+ break;
+ } else if (SpringImplementationConstants.SET_ELEMENT.equals(reader.getName())) {
+ completed = true;
+ break;
+ } else if (SpringImplementationConstants.MAP_ELEMENT.equals(reader.getName())) {
+ completed = true;
+ break;
+ } // end if
+ } // end switch
+ } // end while
+ } catch (XMLStreamException e) {
+ throw new ContributionReadException(e);
+ }
+ }
+
+ /**
+ * 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;
+ // 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);
+ }
+ } // end while
+ } // end if
+
+ itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ // Ignore if the bean has no properties and constructor arguments
+ if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
+ continue;
+
+ 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);
+ 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();
+
+ Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
+ while (itp.hasNext()) {
+ SpringPropertyElement propertyElement = itp.next();
+ 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);
+ } // 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);
+ } // 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())))
+ {
+ if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Reference")) {
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ componentType.getReferences().add(theReference);
+ }
+ if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Property")) {
+ // 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
+
+ } // 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);
+ } catch (ContributionResolveException 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) 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("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("DefaultBeanDoesNotExist", beans);
+ if (!isUniqueReferenceName)
+ error("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("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 \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java
new file mode 100644
index 0000000000..b97c02d216
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/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.invocation;
+
+/**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java
new file mode 100644
index 0000000000..89d14961ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/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.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+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 JavaPropertyValueObjectFactory propertyFactory;
+
+ public PropertyValueTie(RuntimeComponent component, JavaPropertyValueObjectFactory 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.createValueFactory(prop, prop.getValue(), type).getInstance();
+ }
+ }
+ return null; // property name not found
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
new file mode 100644
index 0000000000..dcb9a53a33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.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.spring.invocation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+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 Object tie;
+ private Method startMethod;
+ private Method closeMethod;
+ private Method getBeanMethod;
+
+ public SpringContextStub(RuntimeComponent component,
+ SpringImplementation implementation,
+ ProxyFactory proxyService,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+
+ initTie(component, implementation, propertyValueObjectFactory);
+
+ }
+
+ private void initTie(RuntimeComponent component,
+ SpringImplementation implementation,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+
+ // TODO: what class loader to use?
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+
+ try {
+
+ Class<?> stubClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringImplementationStub", true, cl);
+ Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[]{Object.class});
+ Object stub = stubConstructor.newInstance(new SpringImplementationTie(implementation, component, propertyValueObjectFactory));
+
+ Class<?> tieClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringContextTie", 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);
+ }
+ }
+
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
new file mode 100644
index 0000000000..0ecd00d5a8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.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.spring.invocation;
+
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+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;
+
+ private SpringImplementation implementation;
+
+ private JavaPropertyValueObjectFactory propertyValueObjectFactory;
+
+ /**
+ * 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,
+ ProxyFactory proxyService,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+ super();
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyValueObjectFactory = propertyValueObjectFactory;
+
+ springContext = new SpringContextStub(component, implementation, 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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
new file mode 100644
index 0000000000..5dfdbffd84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.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.invocation;
+
+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.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+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 JavaPropertyValueObjectFactory propertyFactory;
+
+ /**
+ * Simple constructor
+ *
+ */
+ public SpringImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ super();
+
+ ProxyFactoryExtensionPoint proxyFactories = extensionPoints.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ proxyFactory = new ExtensibleProxyFactory(proxyFactories);
+
+ // TODO: could the runtime have a default PropertyValueObjectFactory?
+ propertyFactory = new JavaPropertyValueObjectFactory(new MediatorImpl(extensionPoints));
+ }
+
+ /**
+ * 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) {
+ return new SpringImplementationProvider(component,
+ implementation,
+ proxyFactory,
+ propertyFactory);
+ }
+
+ /**
+ * Returns the class of the Spring implementation
+ */
+ public Class<SpringImplementation> getModelType() {
+ return SpringImplementation.class;
+ }
+} // end class SpringImplementationProviderFactory
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
new file mode 100644
index 0000000000..6caa5207e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.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.implementation.spring.invocation;
+
+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.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+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 RuntimeComponent component;
+ private JavaPropertyValueObjectFactory propertyFactory;
+
+ public SpringImplementationTie(SpringImplementation implementation, RuntimeComponent component, JavaPropertyValueObjectFactory propertyFactory) {
+ this.implementation = implementation;
+ this.component = component;
+ this.propertyFactory = propertyFactory;
+ }
+
+ public String getURI() {
+ throw new IllegalStateException("Not yet impl");
+ }
+
+ 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
+ ObjectFactory<?> factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
+ propertyObject = (B)factory.getInstance();
+ } // 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);
+
+ } // 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();
+ }
+
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
new file mode 100644
index 0000000000..6a23830aa9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/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.invocation;
+
+/**
+ * @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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
new file mode 100644
index 0000000000..1f9796ccc4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.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.spring.invocation;
+
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
new file mode 100644
index 0000000000..0cd85d1e33
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.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.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.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 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 METAINF/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 = reader.getAttributeValue(null, 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, monitor);
+ 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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..501eb945d8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.spring
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..b04b952fae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.spring,model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..edd3d2e529
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/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.invocation.SpringImplementationProviderFactory;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties
new file mode 100644
index 0000000000..28bd31ca11
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml
new file mode 100644
index 0000000000..d03e42a7a2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <sca:implementationType type="sca:implementation.spring" mayProvide="" alwaysProvides=""/>
+
+ </sca:definitions>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/LICENSE
new file mode 100644
index 0000000000..fa1256bf99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..25c648a0ce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/META-INF/MANIFEST.MF
@@ -0,0 +1,32 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Client
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397153500
+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.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.annotation;version="2.0.0",
+ org.oasisopen.sca;version="2.0.0"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/NOTICE
new file mode 100644
index 0000000000..e158926510
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/pom.xml
new file mode 100644
index 0000000000..3c929df9d7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</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.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientImplementationProvider.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientImplementationProvider.java
new file mode 100644
index 0000000000..f688e103cd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientImplementationProvider.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.client;
+
+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 ClientImplementationProvider implements ImplementationProvider {
+
+ public Invoker createInvoker(RuntimeComponentService arg0, Operation arg1) {
+ return null;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public boolean supportsOneWayInvocation() {
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientProviderFactory.java
new file mode 100644
index 0000000000..efddb002c1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientProviderFactory.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.web.client;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+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.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.implementation.web.runtime.WebImplementationProviderFactory;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+public class ClientProviderFactory extends WebImplementationProviderFactory {
+
+ private ServletHost servletHost;
+
+ public ClientProviderFactory(ExtensionPointRegistry extensionPoints) {
+ super(extensionPoints);
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (!hosts.isEmpty()) {
+ this.servletHost = hosts.get(0);
+ }
+ }
+
+ 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()) {
+ clientServlet.addService(cr, component);
+ }
+ }
+
+ servletHost.setAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent", component);
+
+ return new ClientImplementationProvider();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java
new file mode 100644
index 0000000000..0917804d65
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.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.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.assembly.ComponentReference;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+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, ServiceHolder> services;
+// 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.services = new HashMap<String, ServiceHolder>();
+// 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 : services.keySet()) {
+ String path = request.getServletPath() + "/" + services.get(serviceName).c.getName();
+ 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(ComponentReference cr, RuntimeComponent c) {
+ ServiceHolder holder = new ServiceHolder();
+ holder.name = cr.getName();
+ holder.cr = cr;
+ holder.c = c;
+ services.put(cr.getName(), holder);
+ }
+
+ /**
+ * Defines each SCA service proxy instance to DWR
+ */
+ private void initServices() {
+ CreatorManager creatorManager = (CreatorManager)getContainer().getBean(CreatorManager.class.getName());
+
+ for (final ServiceHolder service : services.values()) {
+
+ final Class<?> iface = ((JavaInterface)service.cr.getInterfaceContract().getInterface()).getJavaClass();
+ final Object instance = service.c.getComponentContext().getServiceReference(iface, service.cr.getName()).getService();
+
+ creatorManager.addCreator(service.cr.getName(), new AbstractCreator() {
+ public Class<?> getType() {
+ return iface;
+ }
+
+ public Object getInstance() throws InstantiationException {
+ return instance;
+ }
+ });
+ }
+ }
+
+ // utility class to aid passing around services
+ private class ServiceHolder {
+ String name;
+ ComponentReference cr;
+ RuntimeComponent c;
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
new file mode 100644
index 0000000000..12122b83e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory
@@ -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.ClientProviderFactory;model=org.apache.tuscany.sca.implementation.web.WebImplementation;ranking=1234
+
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/LICENSE
new file mode 100644
index 0000000000..f602cf9395
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..47adbca335
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Runtime
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397153500
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/NOTICE
new file mode 100644
index 0000000000..d989435591
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/NOTICE
@@ -0,0 +1,12 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/pom.xml
new file mode 100644
index 0000000000..850ebff6c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/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-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</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>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java
new file mode 100644
index 0000000000..3862889f27
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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, R extends ServiceReference<B>> R 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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java
new file mode 100644
index 0000000000..ef1e6cd1b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.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.runtime;
+
+import java.util.List;
+
+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.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;
+
+ public WebImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
+ ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class);
+ List<ServletHost> hosts = servletHosts.getServletHosts();
+ if (!hosts.isEmpty()) {
+ this.servletHost = hosts.get(0);
+ }
+ }
+
+ 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));
+
+ return 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;
+ }
+ };
+ }
+
+ public Class<WebImplementation> getModelType() {
+ return WebImplementation.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld b/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld
new file mode 100644
index 0000000000..8a9ce93204
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..89d94b69fa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Web Implementation Web Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397153500
+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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/NOTICE
new file mode 100644
index 0000000000..1325efd8bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/pom.xml
new file mode 100644
index 0000000000..14d0899b4e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-monitor</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java
new file mode 100644
index 0000000000..29c497485f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.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;
+
+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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java
new file mode 100644
index 0000000000..df2e6c5520
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
new file mode 100644
index 0000000000..e984577cb4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.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.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 uri;
+ private boolean unresolved;
+
+ private String webURI;
+
+ /**
+ * 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 getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java
new file mode 100644
index 0000000000..3723ec57f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.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.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);
+ }
+
+ // 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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..7881092890
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.web
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..ee5f312b8f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#implementation.web,model=org.apache.tuscany.sca.implementation.web.WebImplementation,factory=org.apache.tuscany.sca.implementation.web.WebImplementationFactory
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite b/tags/java/sca/2.0-M4-RC2/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite
new file mode 100644
index 0000000000..864318b22e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://sample/web"
+ xmlns:sc="http://sample/composite"
+ name="TestWeb">
+
+ <component name="TestWeb">
+ <implementation.web web-uri="MyWebapp"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4fa91e0b45
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/META-INF/MANIFEST.MF
@@ -0,0 +1,50 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany Java Interface for JAXWS
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397232156
+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.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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/pom.xml
new file mode 100644
index 0000000000..8ea3f1b5c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-databinding-jaxb</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-interface-java</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
new file mode 100644
index 0000000000..1d6b002361
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 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.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.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;
+
+/**
+ * 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;
+
+
+ public JAXWSJavaInterfaceProcessor(ExtensionPointRegistry registry) {
+ dataBindingExtensionPoint = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+ faultExceptionMapper = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(FaultExceptionMapper.class);
+ xmlAdapterExtensionPoint = registry.getExtensionPoint(XMLAdapterExtensionPoint.class);
+ }
+
+
+ public JAXWSJavaInterfaceProcessor(DataBindingExtensionPoint dataBindingExtensionPoint,
+ FaultExceptionMapper faultExceptionMapper,
+ XMLAdapterExtensionPoint xmlAdapters) {
+ super();
+ this.dataBindingExtensionPoint = dataBindingExtensionPoint;
+ this.faultExceptionMapper = faultExceptionMapper;
+ this.xmlAdapterExtensionPoint = xmlAdapters;
+ }
+
+ 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();
+ WebService webService = clazz.getAnnotation(WebService.class);
+ String tns = JavaXMLMapper.getNamespace(clazz);
+ String localName = clazz.getSimpleName();
+ if (webService != null) {
+ tns = getValue(webService.targetNamespace(), tns);
+ localName = getValue(webService.name(), localName);
+ contract.setQName(new QName(tns, localName));
+ // Mark SEI as Remotable
+ contract.setRemotable(true);
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl
new file mode 100644
index 0000000000..56a753f4ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl b/tags/java/sca/2.0-M4-RC2/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl
new file mode 100644
index 0000000000..494617f988
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/interface-java/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/interface-java/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..65e69260bd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/META-INF/MANIFEST.MF
@@ -0,0 +1,43 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Java Interface Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397130359
+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.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.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;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/tags/java/sca/2.0-M4-RC2/modules/interface-java/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/interface-java/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/interface-java/pom.xml
new file mode 100644
index 0000000000..6090424ce0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java
new file mode 100644
index 0000000000..1e36b95da3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java
new file mode 100644
index 0000000000..0a2edb02c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.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.interfacedef.java;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.interfacedef.Interface;
+
+/**
+ * Represents a Java interface.
+ *
+ * @version $Rev$ $Date$
+ */
+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);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java
new file mode 100644
index 0000000000..e3a84c63f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.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.interfacedef.java;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * Represents a Java interface contract.
+ * JavaInterfaceContract
+ *
+ * @version $Rev$ $Date$
+ */
+public interface JavaInterfaceContract extends InterfaceContract {
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
new file mode 100644
index 0000000000..c849a1acfa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.interfacedef.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java
new file mode 100644
index 0000000000..e6cb35cc4b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.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.interfacedef.java;
+
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+
+/**
+ * Represents a Java operation.
+ *
+ * @version $Rev$ $Date$
+ */
+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);
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java
new file mode 100644
index 0000000000..d43ebe558b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.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.impl;
+
+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 {
+
+ protected JavaInterfaceContractImpl() {
+ }
+
+ @Override
+ public JavaInterfaceContractImpl clone() throws CloneNotSupportedException {
+ return (JavaInterfaceContractImpl) super.clone();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
new file mode 100644
index 0000000000..b443cb988e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.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.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);
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java
new file mode 100644
index 0000000000..0b418054c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.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.interfacedef.java.impl;
+
+import java.lang.ref.WeakReference;
+
+import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.interfacedef.impl.InterfaceImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+
+/**
+ * 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;
+
+ protected JavaInterfaceImpl() {
+ }
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
new file mode 100644
index 0000000000..e903783300
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.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.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.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("@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);
+
+ 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();
+ 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;
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java
new file mode 100644
index 0000000000..2a9e3c5329
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.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.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.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$
+ */
+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) {
+ 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);
+ }
+
+ /**
+ * @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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java
new file mode 100644
index 0000000000..4384213bf5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.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.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;
+
+ 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;
+ }
+
+ @Override
+ public String toString() {
+ return method == null ? "null" : method.toGenericString();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java
new file mode 100644
index 0000000000..1610a2e8ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.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.impl;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+
+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.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, List<Intent> requiredIntents, List<PolicySet> policySets) {
+ 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));
+ requiredIntents.add(intent);
+ }
+ }
+ }
+
+ readSpecificIntents(clazz.getAnnotations(), requiredIntents);
+
+ 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));
+ policySets.add(policySet);
+ }
+ }
+ }
+ }
+
+ 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 visitInterface(JavaInterface javaInterface) throws InvalidInterfaceException {
+
+ if (javaInterface.getJavaClass() != null) {
+ readIntentsAndPolicySets(javaInterface.getJavaClass(), javaInterface.getRequiredIntents(), javaInterface
+ .getPolicySets());
+
+ // 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());
+ }
+ }
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java
new file mode 100644
index 0000000000..75816b1d36
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java
new file mode 100644
index 0000000000..519ce7b36f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.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.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 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.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.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/200903";
+ private JavaInterfaceFactory javaFactory;
+
+
+ public JavaInterfaceProcessor(FactoryExtensionPoint modelFactories) {
+ this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.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));
+ }
+
+
+ // 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());
+ }
+
+ JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface();
+ if (javaCallbackInterface != null && javaCallbackInterface.getName() != null) {
+ writer.writeAttribute(CALLBACK_INTERFACE, javaCallbackInterface.getName());
+ }
+
+ 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);
+
+ } 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);
+
+ 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());
+ }
+ }
+ }
+ 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;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..7f133c0ba7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#interface.java,model=org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties
new file mode 100644
index 0000000000..3aef8f69ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/main/resources/interface-javaxml-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.
+#
+#
+ClassNotFoundException = Class Not Found Exception: {0}
+ContributionResolveException = ContributionResolveException occurred due to: {0}
+InvalidInterfaceException = InvalidInterfaceException due to: {0}
+ForbiddenAnnotationJCA30006 = JCA30006 Forbidden annotation {0} found in class {1}
+ForbiddenAnnotationJCA30007 = JCA30007 Forbidden annotation {0} found in class {1}
+ForbiddenAnnotationJCA30008 = JCA30008 Forbidden annotation {0} found in class {1}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..88ef90edbe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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(1, type.getOperations().get(0).getRequiredIntents().size());
+ assertEquals(1, type.getOperations().get(1).getRequiredIntents().size());
+ assertEquals(1, type.getPolicySets().size());
+ assertEquals(1, type.getOperations().get(0).getPolicySets().size());
+ assertEquals(1, 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite
new file mode 100644
index 0000000000..ffc38c7f04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:calc="http://sample.calculator"
+ 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" 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/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..bf58f29447
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903">
+
+ <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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b88aa2a141
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/META-INF/MANIFEST.MF
@@ -0,0 +1,48 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA WSDL Interface Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397282593
+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.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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/pom.xml
new file mode 100644
index 0000000000..1cc1526668
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/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>tuscany-modules</artifactId>
+ <version>2.0-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.2</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java
new file mode 100644
index 0000000000..26404958e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java
new file mode 100644
index 0000000000..037dffeadc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java
new file mode 100644
index 0000000000..039e75f437
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.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.interfacedef.wsdl;
+
+import java.net.URI;
+import java.util.List;
+
+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);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java
new file mode 100644
index 0000000000..4e331c1fa4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java
new file mode 100644
index 0000000000..90f846b2fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java
new file mode 100644
index 0000000000..59db17116b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java
new file mode 100644
index 0000000000..0b707163da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java
new file mode 100644
index 0000000000..d73cccb714
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
new file mode 100644
index 0000000000..82a7aa1200
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java
@@ -0,0 +1,284 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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;
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java
new file mode 100644
index 0000000000..e10bc0d178
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.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.wsdl.impl;
+
+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();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java
new file mode 100644
index 0000000000..f863ff696d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.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.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.ConversationSequence;
+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/200903", "requires");
+ private static final QName POLICY_CONVERSATIONAL = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "conversational");
+ public static final QName POLICY_END_CONVERSATION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "endsConversation");
+
+ private static final QName CALLBACK_ATTRIBUTE = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "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);
+ if(isEndConversation(wsdlOp)) {
+ operation.setConversationSequence(ConversationSequence.CONVERSATION_END);
+ }
+ 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));
+ wsdlInterface.setConversational(isConversational(portType));
+ }
+
+ 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();
+
+ //ignores conversational, as it will have it's own
+ //attribute in the wsdl interface model
+ if(! intentName.equals(POLICY_CONVERSATIONAL)) {
+
+ // Add each intent to the list
+ Intent intent = policyFactory.createIntent();
+ intent.setName(intentName);
+
+ wsdlInterface.getRequiredIntents().add(intent);
+ }
+ }
+
+ }
+ }
+
+ private boolean isConversational(PortType portType) {
+ boolean conversational = false;
+
+ 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;
+
+ if(policyAttributes.contains(POLICY_CONVERSATIONAL)) {
+ return true;
+ }
+
+ }
+
+ return conversational;
+ }
+
+ private boolean isEndConversation(javax.wsdl.Operation operation) {
+ boolean endConversation = false;
+
+ Object o;
+ try {
+ o = operation.getExtensionAttribute(POLICY_END_CONVERSATION);
+ } catch (NoSuchMethodError e) {
+ // That method does not exist on older WSDL4J levels
+ o = null;
+ }
+ if(o != null && o instanceof String) {
+ endConversation = Boolean.valueOf((String)o);
+ }
+
+ return endConversation;
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java
new file mode 100644
index 0000000000..a223b5cbd7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.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.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.ConversationSequence;
+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.setConversationSequence(ConversationSequence.CONVERSATION_NONE);
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java
new file mode 100644
index 0000000000..3612fa7756
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
new file mode 100644
index 0000000000..8291ef74ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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);
+ }
+ return wsdlDefinition;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java
new file mode 100644
index 0000000000..8c4a986525
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.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.interfacedef.wsdl.xml;
+
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+
+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.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;
+
+/**
+ * Handles a <interface.wsdl ... /> element in a SCDL file
+ * @version $Rev$ $Date$
+ */
+public class WSDLInterfaceProcessor implements StAXArtifactProcessor<WSDLInterfaceContract>, WSDLConstants {
+
+ private WSDLFactory wsdlFactory;
+
+ private InterfaceContractMapper interfaceContractMapper;
+
+ 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);
+ }
+ /**
+ * 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 = reader.getAttributeValue(null, INTERFACE);
+ if (uri != null) {
+ WSDLInterface wsdlInterface = createWSDLInterface(uri, monitor);
+ if (wsdlInterface != null)
+ wsdlInterfaceContract.setInterface(wsdlInterface);
+ }
+
+ uri = reader.getAttributeValue(null, 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);
+ }
+
+ // 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());
+ }
+
+ 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 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);
+ 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();
+ // Resolve the interface and callback interface
+ WSDLInterface wsdlInterface = resolveWSDLInterface((WSDLInterface)wsdlInterfaceContract.getInterface(), 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.isEqual(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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
new file mode 100644
index 0000000000..4351c2ac54
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java
@@ -0,0 +1,535 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.wsdl.Definition;
+import javax.wsdl.Operation;
+import javax.wsdl.PortType;
+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 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.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";
+
+ //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/200903", "requires");
+ public static final QName Q_POLICY_END_CONVERSATION_ATTRIBUTE_EXTENSION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "endsConversation");
+ // ---- SCA Callback WSDL Extension
+ public static final QName Q_CALLBACK_ATTRIBUTE_EXTENSION = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "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;
+
+ public WSDLLocatorImpl(ProcessorContext context, URL base, InputStream is) {
+ this.context = context;
+ this.base = base;
+ this.inputStream = is;
+ }
+
+ 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 (Exception e) {
+ 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) {
+ if (definitions == null || definitions.size() == 0) {
+ return null;
+ }
+ if (definitions.size() == 1) {
+ WSDLDefinition d = definitions.get(0);
+ loadOnDemand(d, context);
+ return d;
+ }
+ WSDLDefinition aggregated = wsdlFactory.createWSDLDefinition();
+ for (WSDLDefinition d : definitions) {
+ loadOnDemand(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 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(namespace)) {
+ if (namespaceImport.getLocation() == null) {
+ // 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 {
+ // We might have multiple imports for the same namespace,
+ // need to search them in lexical order.
+ locations.add(namespaceImport.getLocation());
+ locationMap.put(namespaceImport.getLocation(), namespaceImport);
+ }
+ }
+ } 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);
+ }
+ }
+ }
+ // 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(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);
+ resolved = aggregate(list, context);
+ if (resolved != null && !resolved.isUnresolved()) {
+ return modelClass.cast(resolved);
+ }
+
+ return modelClass.cast(unresolved);
+ }
+
+ /**
+ * Load the WSDL definition on demand
+ * @param def
+ * @param context
+ */
+ private void loadOnDemand(WSDLDefinition def, ProcessorContext context) {
+ if (def.getDefinition() == null && def.getLocation() != null) {
+ // Load the definition on-demand
+ try {
+ loadDefinition(def, context);
+ } catch (ContributionReadException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ // private Map<String, WSDLDefinition> loadedDefinitions = new Hashtable<String, WSDLDefinition>();
+
+ /**
+ * 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 || wsdlDef.getLocation() == null) {
+ return;
+ }
+ try {
+ URL 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
+
+ WSDLLocatorImpl locator = new WSDLLocatorImpl(context, artifactURL, is);
+ 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 = resolveModel(WSDLDefinition.class, wsdlDefinition, context);
+ if (!resolved.isUnresolved()) {
+ for (javax.wsdl.Import imp : entry.getValue()) {
+ if (resolved.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) {
+ // this WSDLDefinition contains the imported document
+ wsdlDef.getImportedDefinitions().add(resolved);
+ } else {
+ // this is a facade, so look in its imported definitions
+ for (WSDLDefinition def : resolved.getImportedDefinitions()) {
+ if (def.getDefinition().getDocumentBaseURI().equals(imp.getDefinition().getDocumentBaseURI())) {
+ wsdlDef.getImportedDefinitions().add(def);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ //Read inline schemas
+ readInlineSchemas(wsdlDef, definition, context);
+ } catch (WSDLException 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);
+ }
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..08fa2b7474
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903#interface.wsdl,model=org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterfaceContract
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties
new file mode 100644
index 0000000000..11756711be
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/main/resources/interface-wsdlxml-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 : {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. \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java
new file mode 100644
index 0000000000..4172eb2955
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.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.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.ConversationSequence;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.Operation;
+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");
+ Assert.assertTrue(contract.isConversational());
+
+ boolean foundIntent = false;
+
+ for(Intent intent : contract.getRequiredIntents()) {
+ if(INTENT.equals(intent.getName())) {
+ foundIntent = true;
+ }
+ }
+
+ Assert.assertTrue(foundIntent);
+
+ for(Operation operation : contract.getOperations()) {
+ if(operation.getName().equals("cancel")) {
+ Assert.assertEquals(operation.getConversationSequence(), ConversationSequence.CONVERSATION_END);
+ }
+ }
+
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite
new file mode 100644
index 0000000000..fcdf69594b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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"/>
+ </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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType
new file mode 100644
index 0000000000..35052dfd6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl
new file mode 100644
index 0000000000..813d9e8291
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl
new file mode 100644
index 0000000000..9d9376ad6c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl
new file mode 100644
index 0000000000..3885357625
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd
new file mode 100644
index 0000000000..635ca25bfc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd
new file mode 100644
index 0000000000..bb0c9bc7b7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/name.xsd b/tags/java/sca/2.0-M4-RC2/modules/interface-wsdl/src/test/resources/xsd/name.xsd
new file mode 100644
index 0000000000..300de931ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/launcher/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/launcher/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/launcher/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/launcher/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a8c4d91321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/launcher/META-INF/MANIFEST.MF
@@ -0,0 +1,28 @@
+Manifest-Version: 1.0
+Archiver-Version: Plexus Archiver
+Created-By: 1.6.0 (IBM Corporation)
+Built-By: gb000131
+Build-Jdk: 1.6.0
+Extension-Name: tuscany-launcher
+Implementation-Title: Apache Tuscany Launcher
+Implementation-Vendor: The Apache Software Foundation
+Implementation-Vendor-Id: org.apache
+Implementation-Version: 2.0-SNAPSHOT
+Specification-Title: Apache Tuscany Launcher
+Specification-Vendor: The Apache Software Foundation
+Specification-Version: 2.0-SNAPSHOT
+Bundle-DocURL: http://www.apache.org/
+Bundle-SymbolicName: org.apache.tuscany.sca.launcher
+Originally-Created-By: 1.6.0 (IBM Corporation)
+Bundle-Version: 2.0
+Bundle-Description: Apache Tuscany Launcher
+Bundle-Vendor: The Apache Software Foundation
+Bnd-LastModified: 1231166325921
+Bundle-Name: Apache Tuscany Launcher
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Tool: Bnd-0.0.255
+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/tags/java/sca/2.0-M4-RC2/modules/launcher/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/launcher/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/launcher/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/tags/java/sca/2.0-M4-RC2/modules/launcher/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/launcher/pom.xml
new file mode 100644
index 0000000000..94aef6bb28
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-launcher</artifactId>
+ <name>Apache Tuscany SCA Launcher</name>
+
+ <dependencies>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java b/tags/java/sca/2.0-M4-RC2/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java
new file mode 100644
index 0000000000..84affffc46
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.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.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 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());
+ 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/tags/java/sca/2.0-M4-RC2/modules/monitor/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/monitor/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/monitor/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ff4e54dd82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/monitor/META-INF/MANIFEST.MF
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.monitor;version="2.0.0"
+Bundle-Name: Apache Tuscany SCA Monitor
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397090921
+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/tags/java/sca/2.0-M4-RC2/modules/monitor/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/monitor/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/monitor/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/tags/java/sca/2.0-M4-RC2/modules/monitor/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/monitor/pom.xml
new file mode 100644
index 0000000000..dbdc8ef0d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-monitor</artifactId>
+ <name>Apache Tuscany SCA Monitor</name>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java
new file mode 100644
index 0000000000..8a99fa4c7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java
new file mode 100644
index 0000000000..0f4e7d71ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.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.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$
+ */
+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.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 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.ERROR,
+ 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);
+
+ // =====================================================
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java
new file mode 100644
index 0000000000..12ac7eba7b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java
new file mode 100644
index 0000000000..3c8fa80fc3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.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.monitor;
+
+/**
+ * Records an validation problem.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Problem {
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java
new file mode 100644
index 0000000000..c81581aae0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java
new file mode 100644
index 0000000000..acfc409856
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory
new file mode 100644
index 0000000000..f2c2a52e78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java
new file mode 100644
index 0000000000..6e44b2d5d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/myfaces/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/myfaces/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/myfaces/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/myfaces/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2b52b751b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/myfaces/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany MyFaces JSF Integration
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bnd-LastModified: 1222833658000
+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/tags/java/sca/2.0-M4-RC2/modules/myfaces/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/myfaces/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/myfaces/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/myfaces/pom.xml
new file mode 100644
index 0000000000..707829be30
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java b/tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java
new file mode 100644
index 0000000000..b1ef8eb3ed
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java
new file mode 100644
index 0000000000..4a05fa5856
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/node-api/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..5e9e481abd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Node API
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+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
+Bnd-LastModified: 1225397189093
+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/tags/java/sca/2.0-M4-RC2/modules/node-api/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/node-api/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/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/tags/java/sca/2.0-M4-RC2/modules/node-api/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/node-api/pom.xml
new file mode 100644
index 0000000000..58f30eac6a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java
new file mode 100644
index 0000000000..3c740d89a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.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.node;
+
+import org.oasisopen.sca.ServiceReference;
+
+
+/**
+ * Provides client access to the services in a domain.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Client {
+
+ /**
+ * 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);
+
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java
new file mode 100644
index 0000000000..f69e18dc63
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java
new file mode 100644
index 0000000000..2e73322917
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java
new file mode 100644
index 0000000000..c45415f153
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.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.node;
+
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+
+
+
+
+/**
+ * Represents an SCA processing node.
+ * A node is loaded with an SCA composites. It can start and stop that composite.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface Node extends Client {
+ 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();
+
+ /**
+ * Destroy the node.
+ */
+ void destroy();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java
new file mode 100644
index 0000000000..a351b7b074
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.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.node;
+
+import static org.apache.tuscany.sca.node.ContributionLocationHelper.getContributionLocations;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.InvocationTargetException;
+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.Map.Entry;
+
+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$
+ */
+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 Map<String, NodeFactory> nodeFactories = new HashMap<String, NodeFactory>();
+
+ protected static void setNodeFactory(NodeFactory factory) {
+// if (nodeFactories.get(Node.DEFAULT_DOMAIN_URI) != null) {
+// throw new IllegalStateException();
+// }
+ nodeFactories.put(Node.DEFAULT_DOMAIN_URI, factory);
+ }
+
+ public static class NodeProxy implements Node, Client {
+ 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 a new SCA node factory instance.
+ *
+ * @return a new SCA node factory
+ */
+ public static NodeFactory getInstance(String domainURI) {
+ NodeFactory nodeFactory = nodeFactories.get(domainURI);
+ if (nodeFactory == null) {
+ try {
+ // 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) {
+ Class<?> factoryImplClass =
+ (Class<?>)factoryDeclaration.getClass().getMethod("loadClass").invoke(factoryDeclaration);
+ nodeFactory = (NodeFactory)factoryImplClass.newInstance();
+ }
+ } catch (ClassNotFoundException e) {
+ // Ignore
+ }
+
+ if (nodeFactory == null) {
+ // Fail back to default impl
+ String className = "org.apache.tuscany.sca.node.impl.NodeFactoryImpl";
+
+ Class<?> cls = Class.forName(className);
+ nodeFactory = (NodeFactory)cls.newInstance();
+ }
+
+ } catch (Exception e) {
+ throw new ServiceRuntimeException(e);
+ }
+ nodeFactories.put(domainURI, nodeFactory);
+ }
+ return nodeFactory;
+ }
+
+ /**
+ * Returns a new SCA node factory instance.
+ *
+ * @return a new SCA node factory
+ */
+ public static NodeFactory newInstance() {
+ return getInstance(Node.DEFAULT_DOMAIN_URI);
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * 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 volatile static int count =0;
+ private NodeConfiguration createConfiguration(Contribution... contributions) {
+ NodeConfigurationFactory factory = this;
+ NodeConfiguration configuration = factory.createNodeConfiguration();
+ configuration.setDomainURI(getDomainURI());
+ // Make sure a unique node URI is created for the same node factory
+ configuration.setURI(Node.DEFAULT_NODE_URI+(count++));
+ if (contributions != null) {
+ for (Contribution c : contributions) {
+ configuration.addContribution(c.getURI(), c.getLocation());
+ }
+ }
+ return configuration;
+ }
+
+ 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() {
+ nodeFactories.remove(getDomainURI());
+ }
+
+ public String getDomainURI() {
+ for (Entry<String, NodeFactory> es : nodeFactories.entrySet()) {
+ if (es.getValue().equals(this)) {
+ return es.getKey();
+ }
+ }
+ return Node.DEFAULT_DOMAIN_URI;
+ }
+
+ /**
+ * 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);
+
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java
new file mode 100644
index 0000000000..53b2bca3f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.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.node;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class NodeFinder {
+
+ private static Map<URI, List<Node>> nodes = new HashMap<URI, List<Node>>();
+
+ public static void addNode(URI domainName, Node node) {
+ List<Node> domainNodes = nodes.get(domainName);
+ if (domainNodes == null) {
+ domainNodes = new ArrayList<Node>();
+ }
+ domainNodes.add(node);
+ nodes.put(domainName, domainNodes);
+ }
+
+ public static Node removeNode(Node node) {
+ for (List<Node> domainNodes : nodes.values()) {
+ if (domainNodes.contains(node)) {
+ domainNodes.remove(node);
+ if (domainNodes.size() < 1) {
+ nodes.remove(domainNodes);
+ }
+ return node;
+ }
+ }
+ return null;
+ }
+
+ public static List<Node> getNodes(URI domainURI) {
+ return nodes.get(domainURI);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java
new file mode 100644
index 0000000000..6ffdde2634
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.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.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();
+ node.destroy();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java
new file mode 100644
index 0000000000..a6dab059a3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java
new file mode 100644
index 0000000000..05c718dbd0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java
new file mode 100644
index 0000000000..a23cef7e81
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java
new file mode 100644
index 0000000000..18fecf8044
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
new file mode 100644
index 0000000000..05ed360d75
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.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.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
+ */
+public interface NodeConfiguration {
+ String DEFAULT_DOMAIN_URI = "http://tuscany.apache.org/sca/1.1/domains/default";
+ String DEFAULT_NODE_URI = "http://tuscany.apache.org/sca/1.1/nodes/default";
+ String DEFAULT_DOMAIN_REGISTRY_URI = "vm://localhost";
+
+ /**
+ * Get the URI of the SCA domain that manages the composite application
+ * @return The URI of the SCA domain
+ */
+ String getDomainURI();
+
+ /**
+ * Get the name of the SCA domain
+ * @return The name of the SCA domain
+ */
+ String getDomainName();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java
new file mode 100644
index 0000000000..71833bc7e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
new file mode 100644
index 0000000000..3d5cb1a94c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.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.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 String getDomainName() {
+ if (domainURI != null) {
+ URI uri = URI.create(domainURI);
+ if (uri.getHost() != null) {
+ return uri.getHost();
+ }
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..3eae6468a1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/META-INF/MANIFEST.MF
@@ -0,0 +1,54 @@
+Manifest-Version: 1.0
+Bundle-Name: Apache Tuscany SCA OSGi Node Implementation
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397240796
+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.osgi.remoteserviceadmin;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.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.apache.tuscany.sca.osgi.remoteserviceadmin;version="2.0.0"
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/pom.xml
new file mode 100644
index 0000000000..34d97f8ed4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution-osgi</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-osgi-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java
new file mode 100644
index 0000000000..09e32ccc56
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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) {
+ // Use the bundle as the key
+ return configuration.getExtensions().get(0);
+ }
+
+ @Override
+ protected ExtensionPointRegistry createExtensionPointRegistry() {
+ return new OSGiExtensionPointRegistry(bundleContext);
+ }
+
+ @Override
+ protected boolean isSchemaValidationEnabled() {
+ return logger.isLoggable(Level.FINE);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointDescription.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointDescription.java
new file mode 100644
index 0000000000..23a91b89ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointDescription.java
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) OSGi Alliance (2008, 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.osgi.remoteserviceadmin;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Constants;
+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. 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 importer. That is, the
+ * property keys have been chosen to match filters that are created by client
+ * bundles that need a service.
+ *
+ * TODO Automatically calculate versions of interface packages?
+ *
+ * TODO Constructor that takes a class?
+ *
+ * TODO Skipping of service.exported.* properties?
+ *
+ * TODO qualified intents?
+ *
+ *
+ *
+ * @Immutable
+ * @version $Revision$
+ */
+
+public class EndpointDescription {
+ private final Map /* <String,Object> */properties = new HashMap/*
+ * <String ,
+ * Object >
+ */();
+ private final List /* String */interfaces;
+ private final long remoteServiceId;
+ private final String remoteFrameworkUUID;
+ private final String remoteUri;
+
+ /**
+ * Create an Endpoint Description based on a Map.
+ *
+ * @param properties
+ * @throws IllegalArgumentException When the properties are not proper for
+ * an Endpoint Description
+ */
+
+ public EndpointDescription(Map/* <String,Object> */properties) throws IllegalArgumentException {
+ this.properties.putAll(properties);
+
+ interfaces = verifyInterfacesProperty();
+ remoteServiceId = verifyLongProperty(RemoteConstants.SERVICE_REMOTE_ID);
+ remoteFrameworkUUID = verifyStringProperty(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID);
+ remoteUri = verifyStringProperty(RemoteConstants.SERVICE_REMOTE_URI);
+ }
+
+ /**
+ * Create an Endpoint Description based on a reference and optionally a map
+ * of additional properties.
+ *
+ * @param ref A service reference that can be exported
+ * @param properties Additional properties to add. Can be <code>null</code>.
+ * @throws IllegalArgumentException
+ */
+ public EndpointDescription(ServiceReference ref, Map /* <String,Object> */properties)
+ throws IllegalArgumentException {
+ if (properties != null) {
+ this.properties.putAll(properties);
+ }
+
+ String[] keys = ref.getPropertyKeys();
+ for (int i = 0; i > keys.length; i++)
+ properties.put(keys[i], ref.getProperty(keys[i]));
+
+ interfaces = verifyInterfacesProperty();
+ remoteServiceId = verifyLongProperty(RemoteConstants.SERVICE_REMOTE_ID);
+ remoteFrameworkUUID = verifyStringProperty(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID);
+ remoteUri = verifyStringProperty(RemoteConstants.SERVICE_REMOTE_URI);
+ }
+
+ /**
+ * Create an Endpoint Description based on the URI, the remote service ID
+ * and the interface names, and optionally service properties.
+ *
+ * @param uri The URI of the remote service.
+ * @param interfaceNames The names of the interfaces of the service to
+ * consider.
+ * @param remoteServiceId the remote service ID.
+ * @param properties Optionally service properties.
+ */
+ public EndpointDescription(String uri, String[] interfaceNames, int remoteServiceId, Map properties) {
+ if (uri == null) {
+ throw new IllegalArgumentException("URI must not be null");
+ }
+ if (interfaceNames == null) {
+ throw new IllegalArgumentException("Interfaces must not be null");
+ }
+ this.remoteUri = uri;
+ this.interfaces = Arrays.asList(interfaceNames);
+ this.remoteServiceId = remoteServiceId;
+ this.remoteFrameworkUUID = (String)properties.get(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID);
+ if (properties != null) {
+ this.properties.putAll(properties);
+ }
+ if (interfaceNames != null) {
+ this.properties.put(Constants.OBJECTCLASS, interfaceNames);
+ }
+ this.properties.put(RemoteConstants.SERVICE_REMOTE_URI, uri);
+ if (remoteServiceId <= 0) {
+ this.properties.put(RemoteConstants.SERVICE_REMOTE_ID, new Integer(remoteServiceId));
+ }
+ }
+
+ /**
+ * Verify and obtain the interface list from the properties.
+ *
+ * @return A list with the interface names.
+ * @throws IllegalArgumentException when
+ */
+ private List /* <String> */verifyInterfacesProperty() {
+ List l = null;
+
+ Object objectClass = properties.get(Constants.OBJECTCLASS);
+ if (objectClass == null)
+ l = Collections.EMPTY_LIST;
+ else if (!(objectClass instanceof String[]))
+ throw new IllegalArgumentException("objectClass must be a String[]");
+ else {
+ l = Collections.unmodifiableList(Arrays.asList((String[])objectClass));
+ for (Iterator i = l.iterator(); i.hasNext();) {
+ String interf = (String)i.next();
+ try {
+ getInterfaceVersion(interf);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("Improper version for interface " + interf + " caused by " + e);
+ }
+ }
+ }
+ return l;
+ }
+
+ /**
+ * Verify and obtain a required String property.
+ *
+ * @param propName The name of the property
+ * @return The value of the property.
+ * @throws IllegalArgumentException when the property is not set or doesn't
+ * have the correct data type.
+ */
+ private String verifyStringProperty(String propName) {
+ Object r = properties.get(propName);
+ if (r == null) {
+ throw new IllegalArgumentException("Required property not set: " + propName);
+ }
+ if (!(r instanceof String)) {
+ throw new IllegalArgumentException("Required property is not a string: " + propName);
+ }
+ return (String)r;
+ }
+
+ /**
+ * Verify and obtain a required long property.
+ *
+ * @param propName The name of the property
+ * @return The value of the property.
+ * @throws IllegalArgumentException when the property is not set or doesn't
+ * have the correct data type.
+ */
+ private long verifyLongProperty(String propName) {
+ Object r = properties.get(propName);
+ long result;
+ if (r == null) {
+ throw new IllegalArgumentException("Required property not set: " + propName);
+ }
+ if (!(r instanceof String)) {
+ throw new IllegalArgumentException("Required property is not a string: " + propName);
+ }
+ try {
+ result = Long.parseLong((String)r);
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Required property cannot be parsed as a long: " + propName);
+ }
+ return result;
+ }
+
+ /**
+ * Returns the endpoint's URI.
+ *
+ * The URI is an opaque id for an endpoint in URI form. No two different
+ * endpoints must have the same URI, two Endpoint Descriptions with the same
+ * URI must represent the same endpoint.
+ *
+ * The value of the URI is stored in the
+ * {@link RemoteConstants#SERVICE_REMOTE_URI} property.
+ *
+ * @return The URI of the endpoint, never <code>null</code>.
+ */
+ public String getRemoteURI() {
+ return remoteUri;
+ }
+
+ /**
+ * Answer the list of interfaces implemented by the exported service.
+ *
+ * If this Endpoint Description does not map to a service, then this List
+ * must be empty.
+ *
+ * The value of the interfaces is derived from the <code>objectClass</code>
+ * property.
+ *
+ * @return The read only list of Java interface names accessible by this
+ * endpoint.
+ */
+ public List/* <String> */getInterfaces() {
+ return interfaces;
+ }
+
+ /**
+ * Answer the version of the given interface.
+ *
+ * The version is encoded by prefixing the given interface name with
+ * <code>endpoint.version.</code>, and then using this as a property key.
+ * The value must then be the <code>Version</code> object. For example:
+ *
+ * <pre>
+ * endpoint.version.com.acme.Foo
+ * </pre>
+ *
+ * @param name The name of the interface for which a version is requested
+ * @return The version of the given interface or <code>null</code> if the
+ * interface has no version in this Endpoint Description
+ */
+ public Version getInterfaceVersion(String name) {
+ String v = (String)properties.get("endpoint.version." + name);
+ if (v == null) {
+ return Version.emptyVersion;
+ } else {
+ return new Version(v);
+ }
+ }
+
+ /**
+ * 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.
+ *
+ * @return Service id of a service or 0 if this Endpoint
+ * Description does not relate to an OSGi service
+ *
+ */
+ public long getRemoteServiceID() {
+ return remoteServiceId;
+ }
+
+ /**
+ * 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 represents the
+ * {@link RemoteConstants#SERVICE_IMPORTED_CONFIGS}
+ *
+ * @return The configuration type used for the associated endpoint and
+ * optionally synonyms.
+ */
+ public List/* <String> */getConfigurationTypes() {
+ // TODO
+ return null;
+ }
+
+ /**
+ * 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.
+ *
+ * The property the intents come from is
+ * {@link RemoteConstants#SERVICE_INTENTS}
+ *
+ * @return A list of expanded intents that are provided by this endpoint.
+ */
+ public List/* <String> */getIntents() {
+ // TODO
+ return null;
+
+ }
+
+ /**
+ * Return the framework UUID, if present.
+ *
+ * The property the intents come from is
+ * {@link RemoteConstants#SERVICE_REMOTE_FRAMEWORK_UUID}
+ *
+ * @return Remote Framework UUID, or null if this endpoint is not associated with an OSGi service
+ */
+ public String getRemoteFrameworkUUID() {
+ return remoteFrameworkUUID;
+ }
+
+ /**
+ * Returns all endpoint properties.
+ *
+ * @return An unmodifiable map referring to the properties of this Endpoint
+ * Description.
+ */
+ public Map/* <String, Object> */getProperties() {
+ // TODO
+ return Collections.unmodifiableMap(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
+ * URI 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 (remoteUri.equals(other.remoteUri))
+ return true;
+
+ if (remoteFrameworkUUID == null)
+ return false;
+
+ return remoteServiceId == other.remoteServiceId && remoteFrameworkUUID.equals(other.remoteFrameworkUUID);
+ }
+
+ /**
+ * Two endpoints are equal if their URIs are equal, the hash code is
+ * therefore derived from the URI.
+ */
+ public int hashCode() {
+ // TODO
+ return getRemoteURI().hashCode();
+ }
+
+ /**
+ * Two endpoints are equal if their URIs are equal.
+ */
+ public boolean equals(Object other) {
+ if (other instanceof EndpointDescription) {
+ return getRemoteURI().equals(((EndpointDescription)other).getRemoteURI());
+ }
+ return false;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointListener.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointListener.java
new file mode 100644
index 0000000000..94c08b7632
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointListener.java
@@ -0,0 +1,112 @@
+package org.apache.tuscany.sca.osgi.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 End Point
+ * Descriptions available in the network and inform the network about available
+ * End Point Descriptions.
+ *
+ * Both the network bundle and the manager bundle register an Endpoint
+ * Listener service. The manager informs the network bundle about End Points
+ * 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 End Point Description to all the End Point
+ * 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
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointPermission.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointPermission.java
new file mode 100644
index 0000000000..4aca1ffb9c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointPermission.java
@@ -0,0 +1,938 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+// TODO Hacked from ServiePermission
+
+/*
+ * Copyright (c) OSGi Alliance (2000, 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.
+ */
+
+import java.io.IOException;
+import java.io.NotSerializableException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.security.BasicPermission;
+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.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+ * A bundle's authority to register or get a service.
+ * <ul>
+ * <li>The <code>register</code> action allows a bundle to register a service
+ * on the specified names.
+ * <li>The <code>get</code> action allows a bundle to detect a service and
+ * get it.
+ * </ul>
+ * Permission to get a service is required in order to detect events regarding
+ * the service. Untrusted bundles should not be able to detect the presence of
+ * certain services unless they have the appropriate
+ * <code>EndpointPermission</code> to get the specific service.
+ *
+ * @ThreadSafe
+ * @version $Revision$
+ */
+
+public final class EndpointPermission extends BasicPermission {
+ static final long serialVersionUID = -7662148639076511574L;
+ /**
+ * The action string <code>get</code>.
+ */
+ public final static String EXPORT = "export";
+ /**
+ * The action string <code>register</code>.
+ */
+ public final static String IMPORT = "import";
+
+ public final static String LISTENING = "listening";
+
+ public final static String READ = "listening";
+
+ private final static int ACTION_EXPORT = 0x00000001;
+ private final static int ACTION_IMPORT = 0x00000002;
+ private final static int ACTION_ALL = ACTION_EXPORT | ACTION_IMPORT;
+ 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 service used by this EndpointPermission. Must be null if not
+ * constructed with a service.
+ */
+ transient final EndpointDescription endpoint;
+
+ /**
+ * The object classes for this EndpointPermission. Must be null if not
+ * constructed with a service.
+ */
+ transient final String[] objectClass;
+
+ /**
+ * If this EndpointPermission was constructed with a filter, this holds a
+ * Filter matching object used to evaluate the filter in implies.
+ */
+ transient Filter filter;
+
+ /**
+ * This dictionary holds the properties of the permission, used to match a
+ * filter in implies. This is not initialized until necessary, and then
+ * cached in this object.
+ */
+ private transient volatile Dictionary properties;
+
+ /**
+ * True if constructed with a name and the name is "*" or ends with ".*".
+ */
+ private transient boolean wildcard;
+
+ /**
+ * If constructed with a name and the name ends with ".*", this contains the
+ * name without the final "*".
+ */
+ private transient String prefix;
+
+ /**
+ * Create a new EndpointPermission.
+ *
+ * <p>
+ * The name of the service is specified as a fully qualified class name.
+ * Wildcards may be used.
+ *
+ * <pre>
+ * name ::= &lt;class name&gt; | &lt;class name ending in &quot;.*&quot;&gt; | *
+ * </pre>
+ *
+ * Examples:
+ *
+ * <pre>
+ * org.osgi.service.http.HttpService
+ * org.osgi.service.http.*
+ * *
+ * </pre>
+ *
+ * For the <code>get</code> action, the name can also be a filter
+ * expression. The filter gives access to the service properties as well as
+ * the following attributes:
+ * <ul>
+ * <li>signer - A Distinguished Name chain used to sign the bundle
+ * publishing the service. Wildcards in a DN are not matched according to
+ * the filter string rules, but according to the rules defined for a DN
+ * chain.</li>
+ * <li>location - The location of the bundle publishing the service.</li>
+ * <li>id - The bundle ID of the bundle publishing the service.</li>
+ * <li>name - The symbolic name of the bundle publishing the service.</li>
+ * </ul>
+ * Since the above attribute names may conflict with service property names
+ * used by a service, you can prefix an attribute name with '@' in the
+ * filter expression to match against the service property and not one of
+ * the above attributes. Filter attribute names are processed in a case
+ * sensitive manner unless the attribute references a service property.
+ * Service properties names are case insensitive.
+ *
+ * <p>
+ * There are two possible actions: <code>get</code> and
+ * <code>register</code>. The <code>get</code> permission allows the
+ * owner of this permission to obtain a service with this name. The
+ * <code>register</code> permission allows the bundle to register a
+ * service under that name.
+ *
+ * @param name
+ * The service class name
+ * @param actions
+ * <code>get</code>,<code>register</code> (canonical order)
+ * @throws IllegalArgumentException
+ * If the specified name is a filter expression and either the
+ * specified action is not <code>get</code> or the filter has
+ * an invalid syntax.
+ */
+ public EndpointPermission(String name, String actions) {
+ this(name, parseActions(actions));
+ if ((filter != null) && ((action_mask & ACTION_ALL) != ACTION_EXPORT)) {
+ throw new IllegalArgumentException("invalid action string for filter expression");
+ }
+ }
+
+ /**
+ * Creates a new requested <code>EndpointPermission</code> object to be
+ * used by code that must perform <code>checkPermission</code> for the
+ * <code>get</code> action. <code>EndpointPermission</code> objects
+ * created with this constructor cannot be added to a
+ * <code>EndpointPermission</code> permission collection.
+ *
+ * @param endpoint
+ * The requested service.
+ * @param actions
+ * The action <code>get</code>.
+ * @throws IllegalArgumentException
+ * If the specified action is not <code>get</code> or
+ * reference is <code>null</code>.
+ * @since 1.5
+ */
+ public EndpointPermission(EndpointDescription endpoint, String actions) {
+ super(createName(endpoint));
+ setTransients(null, parseActions(actions));
+ this.endpoint = endpoint;
+ this.objectClass = (String[])endpoint.getProperties().get(Constants.OBJECTCLASS);
+ if ((action_mask & ACTION_ALL) != ACTION_EXPORT) {
+ throw new IllegalArgumentException("invalid action string");
+ }
+ }
+
+ /**
+ * Create a permission name from a EndpointDescription TODO Needs work
+ *
+ * @param endpoint
+ * EndpointDescription to use to create permission name.
+ * @return permission name.
+ */
+ private static String createName(EndpointDescription endpoint) {
+ if (endpoint == null) {
+ throw new IllegalArgumentException("reference must not be null");
+ }
+ StringBuffer sb = new StringBuffer("(service.id=");
+ // TODO sb.append(endpoint.getProperty(Constants.SERVICE_ID));
+ 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.objectClass = 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;
+ if (f == null) {
+ String name = getName();
+ int l = name.length();
+ /* if "*" or endsWith ".*" */
+ wildcard = ((name.charAt(l - 1) == '*') && ((l == 1) || (name.charAt(l - 2) == '.')));
+ if (wildcard && (l > 1)) {
+ prefix = name.substring(0, l - 1);
+ }
+ }
+ }
+
+ /**
+ * 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 >= 2 && (a[i - 2] == 'g' || a[i - 2] == 'G')
+ && (a[i - 1] == 'e' || a[i - 1] == 'E')
+ && (a[i] == 't' || a[i] == 'T')) {
+ matchlen = 3;
+ mask |= ACTION_EXPORT;
+
+ } else if (i >= 7 && (a[i - 7] == 'r' || a[i - 7] == 'R')
+ && (a[i - 6] == 'e' || a[i - 6] == 'E')
+ && (a[i - 5] == 'g' || a[i - 5] == 'G')
+ && (a[i - 4] == 'i' || a[i - 4] == 'I')
+ && (a[i - 3] == 's' || a[i - 3] == 'S')
+ && (a[i - 2] == 't' || a[i - 2] == 'T')
+ && (a[i - 1] == 'e' || a[i - 1] == 'E')
+ && (a[i] == 'r' || a[i] == 'R')) {
+ matchlen = 8;
+ mask |= ACTION_IMPORT;
+
+ } else {
+ // parse error
+ throw new IllegalArgumentException("invalid permission: " + actions);
+ }
+
+ // make sure we didn't just match the tail of a word
+ // like "ackbarfregister". 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. If the specified filterString is not a
+ * filter expression, then <code>null</code> is returned.
+ * @throws IllegalArgumentException
+ * If the filter syntax is invalid.
+ */
+ private static Filter parseFilter(String filterString) {
+ filterString = filterString.trim();
+ if (filterString.charAt(0) != '(') {
+ return null;
+ }
+
+ 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;
+ }
+ /* we have name of "*" */
+ if (wildcard && (prefix == null)) {
+ return true;
+ }
+ /* if we have a filter */
+ Filter f = filter;
+ if (f != null) {
+ return f.matchCase(requested.getProperties());
+ }
+ /* if requested permission not created with EndpointDescription */
+ String[] requestedNames = requested.objectClass;
+ if (requestedNames == null) {
+ return super.implies(requested);
+ }
+ /* requested permission created with EndpointDescription */
+ if (wildcard) {
+ int pl = prefix.length();
+ for (int i = 0, l = requestedNames.length; i < l; i++) {
+ String requestedName = requestedNames[i];
+ if ((requestedName.length() > pl) && requestedName.startsWith(prefix)) {
+ return true;
+ }
+ }
+ } else {
+ String name = getName();
+ for (int i = 0, l = requestedNames.length; i < l; i++) {
+ if (requestedNames[i].equals(name)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the canonical string representation of the actions. Always
+ * returns present actions in the following order: <code>get</code>,
+ * <code>register</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_EXPORT) == ACTION_EXPORT) {
+ sb.append(EXPORT);
+ comma = true;
+ }
+
+ if ((mask & ACTION_IMPORT) == ACTION_IMPORT) {
+ if (comma)
+ sb.append(',');
+ sb.append(IMPORT);
+ }
+
+ 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 class name and action 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 class name and actions 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 sp = (EndpointPermission)obj;
+
+ return (action_mask == sp.action_mask) && getName().equals(sp.getName())
+ && ((endpoint == sp.endpoint) || ((endpoint != null) && (sp.endpoint != null) && endpoint
+ .equals(sp.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() {
+ Dictionary/*<String, Object>*/result = properties;
+ if (result != null) {
+ return result;
+ }
+ if (endpoint == null) {
+ result = new Hashtable/*<String, Object>*/(1);
+ if (filter == null) {
+ result.put(Constants.OBJECTCLASS, new String[] {getName()});
+ }
+ return properties = result;
+ }
+ final Map props = new HashMap(4);
+ // TODO needs work
+ /*
+ final Bundle bundle = endpoint.getBundle();
+ if (bundle != null) {
+ AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+ props.put("id", new Long(bundle.getBundleId()));
+ props.put("location", bundle.getLocation());
+ String name = bundle.getSymbolicName();
+ if (name != null) {
+ props.put("name", name);
+ }
+ SignerProperty signer = new SignerProperty(bundle);
+ if (signer.isBundleSigned()) {
+ props.put("signer", signer);
+ }
+ return null;
+ }
+ });
+ }
+ */
+ return properties = new Properties(props, endpoint);
+ }
+
+ private static class Properties extends Dictionary {
+ private final Map properties;
+ private final EndpointDescription service;
+
+ Properties(Map properties, EndpointDescription service) {
+ this.properties = properties;
+ this.service = service;
+ }
+
+ public Object get(Object k) {
+ if (!(k instanceof String)) {
+ return null;
+ }
+ String key = (String)k;
+ if (key.charAt(0) == '@') {
+ return service.getProperties().get(key.substring(1));
+ }
+ Object value = properties.get(key);
+ if (value != null) { // fall back to service properties
+ return value;
+ }
+ return service.getProperties().get(key);
+ }
+
+ public int size() {
+ return properties.size() + service.getProperties().size();
+ }
+
+ public boolean isEmpty() {
+ // we can return false because this must never be empty
+ return false;
+ }
+
+ public Enumeration keys() {
+ Collection pk = properties.keySet();
+ String spk[] =
+ (String[])service.getProperties().keySet().toArray(new String[service.getProperties().size()]);
+ List all = new ArrayList(pk.size() + spk.length);
+ all.addAll(pk);
+ add: for (int i = 0, length = spk.length; i < length; i++) {
+ String key = spk[i];
+ for (Iterator iter = pk.iterator(); iter.hasNext();) {
+ if (key.equalsIgnoreCase((String)iter.next())) {
+ continue add;
+ }
+ }
+ all.add(key);
+ }
+ return Collections.enumeration(all);
+ }
+
+ public Enumeration elements() {
+ Collection pk = properties.keySet();
+ String spk[] =
+ (String[])service.getProperties().keySet().toArray(new String[service.getProperties().size()]);
+ List all = new ArrayList(pk.size() + spk.length);
+ all.addAll(properties.values());
+ add: for (int i = 0, length = spk.length; i < length; i++) {
+ String key = spk[i];
+ for (Iterator iter = pk.iterator(); iter.hasNext();) {
+ if (key.equalsIgnoreCase((String)iter.next())) {
+ continue add;
+ }
+ }
+ all.add(service.getProperties().get(key));
+ }
+ return Collections.enumeration(all);
+ }
+
+ public Object put(Object key, Object value) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object remove(Object key) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
+
+/**
+ * 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.
+ *
+ * @GuardedBy this
+ */
+ private transient Map permissions;
+
+ /**
+ * Boolean saying if "*" is in the collection.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private boolean all_allowed;
+
+ /**
+ * Table of permissions with filter expressions.
+ *
+ * @serial
+ * @GuardedBy this
+ */
+ private Map filterPermissions;
+
+ /**
+ * Creates an empty EndpointPermissions object.
+ */
+ public EndpointPermissionCollection() {
+ permissions = new HashMap();
+ 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 sp = (EndpointPermission)permission;
+ if (sp.endpoint != null) {
+ throw new IllegalArgumentException("cannot add to collection: " + sp);
+ }
+
+ final String name = sp.getName();
+ final Filter f = sp.filter;
+ synchronized (this) {
+ /* select the bucket for the permission */
+ Map pc;
+ if (f != null) {
+ pc = filterPermissions;
+ if (pc == null) {
+ filterPermissions = pc = new HashMap();
+ }
+ } else {
+ pc = permissions;
+ }
+ final EndpointPermission existing = (EndpointPermission)pc.get(name);
+
+ if (existing != null) {
+ final int oldMask = existing.action_mask;
+ final int newMask = sp.action_mask;
+ if (oldMask != newMask) {
+ pc.put(name, new EndpointPermission(name, oldMask | newMask));
+ }
+ } else {
+ pc.put(name, sp);
+ }
+
+ 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 perms;
+ synchronized (this) {
+ final int desired = requested.action_mask;
+ /* short circuit if the "*" Permission was added */
+ if (all_allowed) {
+ EndpointPermission sp = (EndpointPermission)permissions.get("*");
+ if (sp != null) {
+ effective |= sp.action_mask;
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
+ }
+
+ String[] requestedNames = requested.objectClass;
+ /* if requested permission not created with EndpointDescription */
+ if (requestedNames == null) {
+ effective |= effective(requested.getName(), desired, effective);
+ if ((effective & desired) == desired) {
+ return true;
+ }
+ }
+ /* requested permission created with EndpointDescription */
+ else {
+ for (int i = 0, l = requestedNames.length; i < l; i++) {
+ if ((effective(requestedNames[i], desired, effective) & desired) == desired) {
+ return true;
+ }
+ }
+ }
+ Map pc = filterPermissions;
+ if (pc == null) {
+ return false;
+ }
+ perms = pc.values();
+ }
+
+ /* iterate one by one over filteredPermissions */
+ for (Iterator iter = perms.iterator(); iter.hasNext();) {
+ if (((EndpointPermission)iter.next()).implies0(requested, effective)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Consult permissions map to compute the effective permission for the
+ * requested permission name.
+ *
+ * @param requestedName
+ * The requested service name.
+ * @param desired
+ * The desired actions.
+ * @param effective
+ * The effective actions.
+ * @return The new effective actions.
+ */
+ private int effective(String requestedName, final int desired, int effective) {
+ final Map pc = permissions;
+ EndpointPermission sp = (EndpointPermission)pc.get(requestedName);
+ // strategy:
+ // Check for full match first. Then work our way up the
+ // name looking for matches on a.b.*
+ if (sp != null) {
+ // we have a direct hit!
+ effective |= sp.action_mask;
+ if ((effective & desired) == desired) {
+ return effective;
+ }
+ }
+ // work our way up the tree...
+ int last;
+ int offset = requestedName.length() - 1;
+ while ((last = requestedName.lastIndexOf(".", offset)) != -1) {
+ requestedName = requestedName.substring(0, last + 1) + "*";
+ sp = (EndpointPermission)pc.get(requestedName);
+ if (sp != null) {
+ effective |= sp.action_mask;
+ if ((effective & desired) == desired) {
+ return effective;
+ }
+ }
+ offset = last - 1;
+ }
+ /*
+ * we don't have to check for "*" as it was already checked before we
+ * were called.
+ */
+ return effective;
+ }
+
+ /**
+ * Returns an enumeration of all the <code>EndpointPermission</code>
+ * objects in the container.
+ *
+ * @return Enumeration of all the EndpointPermission objects.
+ */
+ public synchronized Enumeration elements() {
+ List all = new ArrayList(permissions.values());
+ Map pc = filterPermissions;
+ if (pc != null) {
+ all.addAll(pc.values());
+ }
+ return Collections.enumeration(all);
+ }
+
+ /* serialization logic */
+ private static final ObjectStreamField[] serialPersistentFields =
+ {new ObjectStreamField("permissions", Hashtable.class), new ObjectStreamField("all_allowed", Boolean.TYPE),
+ new ObjectStreamField("filterPermissions", HashMap.class)};
+
+ private synchronized void writeObject(ObjectOutputStream out) throws IOException {
+ Hashtable hashtable = new Hashtable(permissions);
+ ObjectOutputStream.PutField pfields = out.putFields();
+ pfields.put("permissions", hashtable);
+ pfields.put("all_allowed", all_allowed);
+ pfields.put("filterPermissions", filterPermissions);
+ out.writeFields();
+ }
+
+ private synchronized void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
+ ObjectInputStream.GetField gfields = in.readFields();
+ Hashtable hashtable = (Hashtable)gfields.get("permissions", null);
+ permissions = new HashMap(hashtable);
+ all_allowed = gfields.get("all_allowed", false);
+ filterPermissions = (HashMap)gfields.get("filterPermissions", null);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ExportRegistration.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ExportRegistration.java
new file mode 100644
index 0000000000..a2d6f58a3b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ExportRegistration.java
@@ -0,0 +1,61 @@
+package org.apache.tuscany.sca.osgi.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
+ */
+public interface ExportRegistration {
+ /**
+ * Return the service being exported.
+ *
+ * @return The service being exported, must be <code>null</code> when this
+ * registration is unregistered.
+ * @throws IllegalStateException Thrown when this object was not properly initialized, see {@link #getException()}
+ */
+ ServiceReference getExportedService() throws IllegalStateException;
+
+ /**
+ * Return the Endpoint Description that is created for this registration.
+ *
+ * @return the local Endpoint Description
+ * @throws IllegalStateException Thrown when this object was not properly initialized, see {@link #getException()}
+ */
+ EndpointDescription getEndpointDescription();
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ImportRegistration.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ImportRegistration.java
new file mode 100644
index 0000000000..ae9726e798
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ImportRegistration.java
@@ -0,0 +1,60 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+import org.osgi.framework.ServiceReference;
+
+/**
+ * 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
+ */
+public interface ImportRegistration {
+ /**
+ * Answer the associated Service Reference for the proxy to the endpoint.
+ *
+ * @return A Service Reference to the proxy for the endpoint.
+ * @throws IllegalStateException Thrown when this object was not properly initialized, see {@link #getException()}
+ */
+ ServiceReference getImportedService();
+
+ /**
+ * Answer the associated remote Endpoint Description.
+ *
+ * @return A Endpoint Description for the remote endpoint.
+ * @throws IllegalStateException Thrown when this object was not properly initialized, see {@link #getException()}
+ */
+ EndpointDescription getImportedEndpointDescription();
+
+ /**
+ * 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.
+ *
+ * TODO can we assume the proxy service is registered when getException==null?
+ *
+ * @return The exception that occurred during the creation of the
+ * registration or <code>null</code> if no exception occurred.
+ */
+ Throwable getException();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteConstants.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteConstants.java
new file mode 100644
index 0000000000..c3f16aecb7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteConstants.java
@@ -0,0 +1,155 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+/**
+ * Provide the definition of the constants used in the Remote Services API.
+ *
+ * TODO Should some of the properties in chapter 13 go the framework constants?
+ */
+public class RemoteConstants {
+ private RemoteConstants() {
+ }
+
+ /**
+ * The configuration types supported by this Distribution Provider.
+ *
+ * Services that are suitable for distribution list the configuration types
+ * that describe the configuration information for that service in the
+ * {@link #SERVICE_EXPORTED_CONFIGS} or {@link #SERVICE_IMPORTED_CONFIGS}
+ * property.
+ *
+ * A distribution provider must register a service that has this property
+ * and enumerate all configuration types that it supports.
+ *
+ * The type of this property <code>String+</code>
+ *
+ * @see #SERVICE_EXPORTED_CONFIGS
+ * @see #SERVICE_IMPORTED_CONFIGS
+ */
+ public final static String REMOTE_CONFIGS_SUPPORTED = "remote.configs.supported";
+
+ /**
+ * Service property that lists the intents supported by the distribution
+ * provider.
+ *
+ * Each distribution provider must register a service that has this property
+ * and enumerate all the supported intents, having any qualified intents
+ * expanded.
+ *
+ * The value of this property is of type <code>String+</code>.
+ *
+ * @see #SERVICE_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS
+ * @see #SERVICE_EXPORTED_INTENTS_EXTRA
+ */
+ public final static String REMOTE_INTENTS_SUPPORTED = "remote.intents.supported";
+
+ /**
+ * Defines the interfaces under which this service can be exported.
+ *
+ * This list must be a subset of the types listed in the objectClass service
+ * property. The single value of an asterisk ('*' \u002A) indicates all
+ * interfaces in the registration's objectClass property (not classes). It
+ * is highly recommended to only export interfaces and not concrete classes
+ * due to the complexity of creating proxies for some type of classes.
+ *
+ * The value of this property is of type String+.
+ */
+ public final static String SERVICE_EXPORTED_INTERFACES = "service.exported.interfaces";
+
+ /**
+ * A list of 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.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_INTENTS = "service.exported.intents";
+
+ /**
+ * Extra intents configured in addition to the the intents specified in
+ * {@link #SERVICE_EXPORTED_INTENTS}.
+ *
+ * These intents are merged with the service.exported.intents and therefore
+ * have the same semantics. They are extra, so that the
+ * {@link #SERVICE_EXPORTED_INTENTS} can be set by the bundle developer and
+ * this property is then set by the administrator/deployer. Bundles should
+ * make this property configurable, for example through the Configuration
+ * Admin service.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_INTENTS_EXTRA = "service.exported.intents.extra";
+
+ /**
+ * A list of configuration types that should be used to export the service.
+ *
+ * Configuration types can be <em>synonymous</em> or <em>alternatives</em>.
+ * In principle, a distribution provider should create an endpoint for each
+ * recognized configuration type, the deployer is responsible that synonyms
+ * do not clash.
+ *
+ * Each configuration type has an associated specification that describes
+ * how the configuration data for the exported service is represented in an
+ * OSGi framework.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_EXPORTED_CONFIGS = "service.exported.configs";
+
+ /**
+ * Must be set by a distribution provider to <code>true</code> when it
+ * registers the end-point proxy as an imported service. Can be used by a
+ * bundle to prevent it from getting an imported service.
+ *
+ * The value of this property is not defined, setting it is sufficient.
+ */
+ public final static String SERVICE_IMPORTED = "service.imported";
+
+ /**
+ * The configuration type used to import this services, as described in
+ * {@link #SERVICE_EXPORTED_CONFIGS}. 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. Configuration types in this property
+ * must be synonymous.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final String SERVICE_IMPORTED_CONFIGS = "service.imported.configs";
+
+ /**
+ * A list of intents that this service implements. This property has dual
+ * purpose. A bundle can use this service property to notify the
+ * distribution provider that these intents are already implemented by the
+ * exported service object. For an imported service, a distribution provider
+ * must use this property to convey the combined intents of the exporting
+ * service and the intents that the distribution providers add. To export a
+ * service, a distribution provider must recognize all these intents and
+ * expand any qualified intents.
+ *
+ * The value of this property is of type <code>String+</code>.
+ */
+ public final static String SERVICE_INTENTS = "service.intents";
+
+ /**
+ * The property key for the endpoint URI. This is a unique id for an
+ * endpoint following the URI syntax. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_URI = "service.remote.uri";
+
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_ID = "service.remote.id";
+
+ /**
+ * The property key for the endpoint service id. This is a unique id for a
+ * service based on the framework id '.' service id or another model. As far as this specification is
+ * concerned, this unique id is opaque.
+ */
+ final public static String SERVICE_REMOTE_FRAMEWORK_UUID = "service.remote.framework.id";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdmin.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdmin.java
new file mode 100644
index 0000000000..09ad0635f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdmin.java
@@ -0,0 +1,110 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+import java.util.Collection;
+import java.util.List;
+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
+ */
+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.
+ *
+ * If an endpoint can not be created because no
+ * {@link EndpointPermission#EXPORT} can be obtained to export this service,
+ * then this endpoint must be ignored and no Export Registration must be
+ * included in the returned list.
+ *
+ * @param ref 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 or <code>null</code> if the service could
+ * not be exported
+ * @throws IllegalArgumentException
+ * @throws UnsupportedOperationException
+ *
+ * TODO discuss case difference in properties
+ *
+ * TODO More exceptions?
+ * TODO Can you export ANY service by providing the proper properties?
+ */
+ List/* <ExportRegistration> */exportService(ServiceReference ref, Map/* <String,Object> */properties)
+ throws IllegalArgumentException, UnsupportedOperationException;
+
+ /**
+ * 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.
+ *
+ * TODO if the import reg. is valid (getException==null), can we then assume the
+ * service is registered?
+ *
+ * If an endpoint can not be imported because no
+ * {@link EndpointPermission#IMPORT} can be obtained, then this endpoint
+ * must be ignored and no Import Registration must included in the returned
+ * list.
+ *
+ * @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
+ */
+ ImportRegistration importService(EndpointDescription endpoint);
+
+ /**
+ * Answer the currently active Export Registrations.
+ *
+ * @return A collection of Export Registrations that are currently active.
+ * @throws SecurityException When the caller no
+ * {@link EndpointPermission#READ} could be obtained
+ *
+ * TODO I guess we must ensure these registrations cannot be closed? Only the owners should be able to close them,
+ * TODO should we make sure that the list contains the registration objects that the caller created?
+ */
+ Collection/* <ExportRegistration> */getExportedServices();
+
+ /**
+ * Answer the currently active Import Registrations.
+ *
+ * @throws SecurityException When the caller no EndpointPermission LIST
+ * could be obtained
+ * @return A collection of Import Registrations that are currently active.
+ * @throws SecurityException When the caller no
+ * {@link EndpointPermission#READ} could be obtained
+ *
+ * TODO I guess we must ensure these registrations cannot be closed? Only the owners should be able to close them,
+ * TODO should we make sure that the list contains the registration objects that the caller created?
+ */
+ Collection/* <ImportRegistration> */getImportedEndpoints();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminEvent.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminEvent.java
new file mode 100644
index 0000000000..bdb083b940
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminEvent.java
@@ -0,0 +1,149 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ * Provides the event information for a Remote Admin event.
+ *
+ * @Immutable
+ */
+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 ImportRegistration importRegistration;
+ private final ExportRegistration exportRegistration;
+ 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 importRegistration The importRegistration, can be <code>null</code>.
+ * @param exportRegistration The exportRegistration, can be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>
+ */
+ RemoteServiceAdminEvent(int type,
+ Bundle source,
+ ImportRegistration importRegistration,
+ ExportRegistration exportRegistration,
+ Throwable exception) {
+ this.type = type;
+ this.source = source;
+ this.importRegistration = importRegistration;
+ this.exportRegistration = exportRegistration;
+ this.exception = exception;
+ }
+
+ /**
+ * Create a Remote Service Admin Event for an export issue.
+ *
+ * @param type The event type
+ * @param source The source bundle, must not be <code>null</code>.
+ * @param exportRegistration The exportRegistration, can not be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>
+ */
+ public RemoteServiceAdminEvent(int type, Bundle source, ExportRegistration exportRegistration, Throwable exception) {
+ this(type, source, null, exportRegistration, exception);
+ }
+
+ /**
+ * Create a Remote Service Admin Event for an import issue.
+ *
+ * @param type The event type
+ * @param source The source bundle, must not be <code>null</code>.
+ * @param importRegistration The importRegistration, can not be <code>null</code>.
+ * @param exception Any exceptions encountered, can be <code>null</code>
+ */
+ public RemoteServiceAdminEvent(int type, Bundle source, ImportRegistration importRegistration, Throwable exception) {
+ this(type, source, importRegistration, null, exception);
+ }
+
+ /**
+ * @return the importRegistration or <code>null</code>
+ */
+ public ImportRegistration getImportRegistration() {
+ return importRegistration;
+ }
+
+ /**
+ * @return the exportRegistration or <code>null</code>
+ */
+ public ExportRegistration getExportRegistration() {
+ return exportRegistration;
+ }
+
+ /**
+ * @return the exception or <code>null</code>
+ */
+ public Throwable getException() {
+ return exception;
+ }
+
+ /**
+ * @return the type
+ */
+ public int getType() {
+ return type;
+ }
+
+ /**
+ * @return the source
+ */
+ public Bundle getSource() {
+ return source;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminListener.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminListener.java
new file mode 100644
index 0000000000..28a5958704
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminListener.java
@@ -0,0 +1,16 @@
+package org.apache.tuscany.sca.osgi.remoteserviceadmin;
+
+/**
+ * A Remote Service Admin Listener is notified asynchronously of any export or
+ * import registrations and unregistrations.
+ *
+ * @ThreadSafe
+ */
+
+public interface RemoteServiceAdminListener {
+ /**
+ * Receive a Remote Service Admin event.
+ * @param event
+ */
+ void remoteAdminEvent(RemoteServiceAdminEvent event);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/AbstractOSGiServiceHandler.java
new file mode 100644
index 0000000000..7c9cf8ef6e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.newInstance();
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java
new file mode 100644
index 0000000000..d50d1ef9f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.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.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.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+
+/**
+ * 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.getInterfaceContract().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.SERVICE_REMOTE_FRAMEWORK_UUID, uuid);
+ }
+
+ for (Object ext : endpoint.getService().getExtensions()) {
+ if (ext instanceof OSGiProperty) {
+ OSGiProperty prop = (OSGiProperty)ext;
+ props.put(prop.getName(), prop.getStringValue());
+ }
+ }
+
+ props.put(RemoteConstants.SERVICE_REMOTE_ID, props.get(Constants.SERVICE_ID));
+ props.put(RemoteConstants.SERVICE_REMOTE_URI, endpoint.getURI());
+ // FIXME: [rfeng] How to pass in the remote service id from the endpoint XML
+ props.put(RemoteConstants.SERVICE_EXPORTED_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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
new file mode 100644
index 0000000000..a649dac357
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java
@@ -0,0 +1,474 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.implementation.osgi.OSGiProperty.SERVICE_EXPORTED_INTENTS;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_EXPORTED_INTENTS_EXTRA;
+import static org.apache.tuscany.sca.implementation.osgi.OSGiProperty.SERVICE_EXPORTED_INTERFACES;
+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.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 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.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.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.remoteserviceadmin.EndpointDescription;
+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.oasisopen.sca.ServiceRuntimeException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+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 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 {
+ throw new IllegalArgumentException("Invalid intent: " + intentName);
+ }
+ } else {
+ // Default to SCA namespace
+ qname = new QName(Base.SCA11_NS, intentName);
+ }
+ return qname;
+ }
+
+ /**
+ * @param context TODO
+ * @param registry
+ */
+ public EndpointIntrospector(BundleContext context, ExtensionPointRegistry registry, ServiceTracker discoveryTracker) {
+ super();
+ // this.context = context;
+ this.discoveryTracker = discoveryTracker;
+ // this.registry = registry;
+ 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 Reference’s 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 (Constants.OBJECTCLASS.equalsIgnoreCase(p.getKey())) {
+ throw new IllegalArgumentException(Constants.OBJECTCLASS + " property cannot be overridden.");
+ } else if (Constants.SERVICE_ID.equalsIgnoreCase(p.getKey())) {
+ throw new IllegalArgumentException(Constants.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);
+ Long sid = (Long)reference.getProperty(SERVICE_ID);
+
+ String[] requiredIntents = getStringArray(properties.get(SERVICE_EXPORTED_INTENTS));
+ List<Intent> intents = getIntents(requiredIntents);
+ String[] requiredIntentsExtra = getStringArray(properties.get(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(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);
+ return contribution;
+ }
+
+ /**
+ * 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) 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);
+
+ service.getExtensions().add(serviceID);
+
+ implementation.getServices().add(service);
+
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setName(service.getName());
+ 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 = createContribution(bundle, id, composite);
+ return contribution;
+ }
+
+ private Contribution createContribution(Bundle bundle, String id, Composite composite) {
+ Contribution contribution = contributionFactory.createContribution();
+ contribution.setClassLoader(OSGiHelper.createBundleClassLoader(bundle));
+ contribution.setURI("urn:" + id);
+ contribution.setLocation(bundle.getEntry("/").toString());
+ contribution.getDeployables().add(composite);
+ 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());
+ if (ep != null) {
+ bindings = Collections.singletonList(ep.getBinding());
+ interfaces = Collections.singletonList(((JavaInterface)ep.getInterfaceContract().getInterface()).getName());
+ intents = ep.getRequiredIntents();
+ } else {
+ Map<String, Object> properties = endpoint.getProperties();
+ interfaces = endpoint.getInterfaces();
+ String[] requiredIntents = getStringArray(properties.get(SERVICE_EXPORTED_INTENTS));
+ intents = getIntents(requiredIntents);
+
+ String[] bindingNames = getStringArray(properties.get(SCA_BINDINGS));
+ bindings = loadBindings(bindingNames);
+ }
+
+ Contribution contribution = generateContribution(bundle, interfaces, bindings, intents);
+ return contribution;
+ }
+
+ private Contribution generateContribution(Bundle bundle,
+ Collection<String> remoteInterfaces,
+ Collection<Binding> bindings,
+ Collection<Intent> intents) 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());
+ 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 = createContribution(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(interfaceClass);
+ interfaceContract.setInterface(javaInterface);
+ if (javaInterface.getCallbackClass() != null) {
+ interfaceContract.setCallbackInterface(javaInterfaceFactory.createJavaInterface(javaInterface
+ .getCallbackClass()));
+ }
+ 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 (sc.getTargetNamespace().equals(bindingName.getNamespaceURI())) {
+ for (Binding binding : sc.getBindings()) {
+ if (bindingName.getLocalPart().equals(binding.getName())) {
+ bindingMap.put(bindingName, binding);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ for (QName bindingName : bindingNames) {
+ if (!bindingMap.containsKey(bindingName)) {
+ throw new ServiceRuntimeException("Binding cannot be resolved: " + bindingName);
+ }
+ }
+ return bindingMap.values();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java
new file mode 100644
index 0000000000..58d72f389f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.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.osgi.remoteserviceadmin.impl;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Implementation of {@link ExportRegistration}
+ */
+public class ExportRegistrationImpl implements ExportRegistration {
+ private Node node;
+ private ServiceReference exportedService;
+ private EndpointDescription endpointDescription;
+ private Throwable exception;
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ * @param exception
+ */
+ public ExportRegistrationImpl(Node node,
+ ServiceReference exportedService,
+ EndpointDescription endpointDescription,
+ Throwable exception) {
+ super();
+ this.node = node;
+ this.exportedService = exportedService;
+ this.endpointDescription = endpointDescription;
+ this.exception = exception;
+ }
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ */
+ public ExportRegistrationImpl(Node node, ServiceReference exportedService, EndpointDescription endpointDescription) {
+ this(node, exportedService, endpointDescription, null);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration#close()
+ */
+ public void close() {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ exception = null;
+ endpointDescription = null;
+ exportedService = null;
+ }
+
+ public ServiceReference getExportedService() {
+ return exportedService;
+ }
+
+ public EndpointDescription getEndpointDescription() {
+ return endpointDescription;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public Node getNode() {
+ return node;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java
new file mode 100644
index 0000000000..d085bd282d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.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.osgi.remoteserviceadmin.impl;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration;
+import org.osgi.framework.ServiceReference;
+
+/**
+ *
+ */
+public class ImportRegistrationImpl implements ImportRegistration {
+ private Node node;
+ private ServiceReference exportedService;
+ private EndpointDescription endpointDescription;
+ private Throwable exception;
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ * @param exception
+ */
+ public ImportRegistrationImpl(Node node,
+ ServiceReference exportedService,
+ EndpointDescription endpointDescription,
+ Throwable exception) {
+ super();
+ this.node = node;
+ this.exportedService = exportedService;
+ this.endpointDescription = endpointDescription;
+ this.exception = exception;
+ }
+
+ /**
+ * @param exportedService
+ * @param endpointDescription
+ */
+ public ImportRegistrationImpl(Node node, ServiceReference exportedService, EndpointDescription endpointDescription) {
+ super();
+ this.node = node;
+ this.exportedService = exportedService;
+ this.endpointDescription = endpointDescription;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration#close()
+ */
+ public void close() {
+ if (node != null) {
+ node.stop();
+ node = null;
+ }
+ exception = null;
+ endpointDescription = null;
+ exportedService = null;
+ }
+
+ public ServiceReference getImportedService() {
+ return exportedService;
+ }
+
+ public EndpointDescription getImportedEndpointDescription() {
+ return endpointDescription;
+ }
+
+ public Throwable getException() {
+ return exception;
+ }
+
+ public Node getNode() {
+ return node;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java
new file mode 100644
index 0000000000..a4b51d9d0c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.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.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();
+ }
+ String paths[] = value.trim().split("( |\t|\n|\r|\f|,)+");
+ if (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 (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;
+ }
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java
new file mode 100644
index 0000000000..479ae54e42
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.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.osgi.remoteserviceadmin.impl;
+
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants.SERVICE_REMOTE_ID;
+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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+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.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+/**
+ * Watching and exporting OSGi services
+ */
+public class OSGiServiceExporter extends AbstractOSGiServiceHandler implements ServiceTrackerCustomizer {
+
+ /**
+ * @param context
+ * @param clazz
+ * @param customizer
+ */
+ public OSGiServiceExporter(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ init();
+ }
+
+ 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,
+ SERVICE_REMOTE_FRAMEWORK_UUID,
+ getFrameworkUUID(reference.getBundle()
+ .getBundleContext())));
+ service.getExtensions().add(createOSGiProperty(registry, SERVICE_REMOTE_ID, reference
+ .getProperty(SERVICE_ID)));
+
+ // 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);
+ ExportRegistration exportRegistration =
+ new ExportRegistrationImpl(node, reference, endpointDescription);
+ exportedServices.add(exportRegistration);
+ }
+ return exportedServices;
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ 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();
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java
new file mode 100644
index 0000000000..c869ab8c14
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.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.osgi.remoteserviceadmin.impl;
+
+import java.util.Collections;
+
+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.Node;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Watching and exporting OSGi services
+ */
+public class OSGiServiceImporter extends AbstractOSGiServiceHandler {
+
+ /**
+ * @param context
+ * @param clazz
+ * @param customizer
+ */
+ public OSGiServiceImporter(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ // Defer init() to importService()
+ }
+
+ 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()
+ + ")");
+ return new ImportRegistrationImpl(node, serviceReference, endpointDescription);
+ } else {
+ return null;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public void unimportService(ImportRegistration importRegistration) {
+ Node node = (Node)importRegistration.getImportedService().getProperty("sca.node");
+ node.stop();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
new file mode 100644
index 0000000000..9da7b5f014
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdmin;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdminEvent;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdminListener;
+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.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> importedEndpoints = new ArrayList<ImportRegistration>();
+ private Collection<ExportRegistration> exportedServices = 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();
+ registration = context.registerService(RemoteServiceAdmin.class.getName(), this, null);
+ Hashtable<String, Object> 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 : exportedServices) {
+ exportRegistration.close();
+ }
+ exportedServices.clear();
+ for (ImportRegistration importRegistration : importedEndpoints) {
+ importRegistration.close();
+ }
+ importedEndpoints.clear();
+ if (importer != null) {
+ importer.stop();
+ importer = null;
+ }
+ if (exporter != null) {
+ exporter.stop();
+ exporter = null;
+ }
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.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) {
+ exportedServices.addAll(exportRegistrations);
+ 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,
+ 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.getImportRegistration());
+ props.put("export.registration", rsaEvent.getExportRegistration());
+ EndpointDescription ep = null;
+ if (rsaEvent.getImportRegistration() != null) {
+ ep = rsaEvent.getImportRegistration().getImportedEndpointDescription();
+ } else {
+ ep = rsaEvent.getExportRegistration().getEndpointDescription();
+ }
+ props.put("service.remote.id", ep.getRemoteServiceID());
+ props.put("service.remote.uuid", ep.getRemoteFrameworkUUID());
+ props.put("service.remote.uri", ep.getRemoteURI());
+ props.put("objectClass", ep.getInterfaces());
+ props.put("service.imported.configs", ep.getConfigurationTypes());
+ props.put("timestamp", new Long(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, 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.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdmin#getExportedServices()
+ */
+ public Collection<ExportRegistration> getExportedServices() {
+ return exportedServices;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdmin#getImportedEndpoints()
+ */
+ public Collection<ImportRegistration> getImportedEndpoints() {
+ return importedEndpoints;
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.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);
+ importedEndpoints.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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
new file mode 100644
index 0000000000..1967fa6e4a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java
@@ -0,0 +1,410 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants.SERVICE_EXPORTED_CONFIGS;
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants.SERVICE_IMPORTED;
+
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+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.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.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointListener;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ExportRegistration;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.ImportRegistration;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdmin;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdminEvent;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteServiceAdminListener;
+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.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 ServiceRegistration registration;
+ private ServiceRegistration endpointListener;
+
+ private ServiceTracker remotableServices;
+
+ // Service listeners keyed by the filter
+ private CollectionMap<String, ListenerInfo> serviceListeners = new CollectionMap<String, ListenerInfo>();
+
+ private CollectionMap<ServiceReference, ExportRegistration> exportedServices =
+ new CollectionMap<ServiceReference, ExportRegistration>();
+ private CollectionMap<EndpointDescription, ImportRegistration> importedServices =
+ new CollectionMap<EndpointDescription, ImportRegistration>();
+
+ private Filter remotableServiceFilter;
+
+ public TopologyManagerImpl(BundleContext context) {
+ this.context = 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);
+
+ }
+
+ /**
+ * @see org.osgi.framework.hooks.service.EventHook#event(org.osgi.framework.ServiceEvent,
+ * java.util.Collection)
+ */
+ /*
+ public void event(ServiceEvent event, Collection contexts) {
+ ServiceReference reference = event.getServiceReference();
+ if (!remotableServiceFilter.match(reference)) {
+ // Only export remotable services that are for SCA
+ return;
+ }
+ switch (event.getType()) {
+ case ServiceEvent.REGISTERED:
+ exportService(reference);
+ break;
+ case ServiceEvent.UNREGISTERING:
+ unexportService(reference);
+ break;
+ case ServiceEvent.MODIFIED:
+ case ServiceEvent.MODIFIED_ENDMATCH:
+ // First check if the property changes will impact
+ // Call remote admin to update the service
+ unexportService(reference);
+ exportService(reference);
+ break;
+ }
+ }
+ */
+
+ 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;
+ List<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) {
+ synchronized (serviceListeners) {
+ try {
+ Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
+ boolean changed = false;
+ for (ListenerInfo l : listenerInfos) {
+ if (!l.isRemoved() && l.getBundleContext() != context) {
+ String key = l.getFilter();
+ if (key == null) {
+ // key = "";
+ // FIXME: It should always match, let's ignore it for now
+ logger.warning("Service listner without a filter is skipped: " + l);
+ continue;
+ }
+ Collection<ListenerInfo> infos = serviceListeners.get(key);
+ if (infos == null) {
+ infos = new HashSet<ListenerInfo>();
+ serviceListeners.put(key, infos);
+ }
+ infos.add(l);
+ changed = true;
+ }
+ }
+ if (changed) {
+ updateEndpointListenerScope();
+ }
+ } 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() {
+ Set<String> filterSet = serviceListeners.keySet();
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(ENDPOINT_LISTENER_SCOPE, filterSet.toArray(new String[filterSet.size()]));
+ endpointListener.setProperties(props);
+ }
+
+ private CollectionMap<Class<?>, ListenerInfo> findServiceListeners(EndpointDescription endpointDescription,
+ String matchedFilter) {
+ synchronized (serviceListeners) {
+
+ // First find all the listeners that have the matching filter
+ Collection<ListenerInfo> listeners = serviceListeners.get(matchedFilter);
+ if (listeners == null) {
+ return null;
+ }
+
+ // 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 = listeners.iterator(); it.hasNext();) {
+ try {
+ ListenerInfo listener = it.next();
+ if (listener.isRemoved()) {
+ it.remove();
+ continue;
+ }
+ try {
+ 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;
+ }
+ }
+
+ /**
+ * @see org.osgi.framework.hooks.service.ListenerHook#removed(java.util.Collection)
+ */
+ public void removed(Collection listeners) {
+ synchronized (serviceListeners) {
+ try {
+ Collection<ListenerInfo> listenerInfos = (Collection<ListenerInfo>)listeners;
+ boolean changed = false;
+ for (ListenerInfo l : listenerInfos) {
+ if (registration != null && l.getBundleContext() != context) {
+ String key = l.getFilter();
+ if (key == null) {
+ continue;
+ }
+ if (serviceListeners.removeValue(key, l)) {
+ changed = true;
+ }
+ }
+ }
+ if (changed) {
+ updateEndpointListenerScope();
+ }
+ } 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.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointListener#addEndpoint(org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription,
+ * java.lang.String)
+ */
+ public void endpointAdded(EndpointDescription endpoint, String matchedFilter) {
+ importService(endpoint, matchedFilter);
+ }
+
+ /**
+ * @see org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointListener#removeEndpoint(org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription)
+ */
+ public void endpointRemoved(EndpointDescription endpoint, String matchedFilter) {
+ unimportService(endpoint);
+ }
+
+ private void importService(EndpointDescription endpoint, String matchedFilter) {
+ Object[] admins = remoteAdmins.getServices();
+ if (admins == null) {
+ logger.warning("No RemoteAdmin services are available.");
+ return;
+ }
+
+ CollectionMap<Class<?>, ListenerInfo> interfaceToListeners = findServiceListeners(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();
+
+ 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(endpoint, importRegistration);
+ }
+ }
+ }
+ }
+ }
+
+ private void unimportService(EndpointDescription endpoint) {
+ // Call remote admin to unimport the service
+ Collection<ImportRegistration> importRegistrations = importedServices.get(endpoint);
+ 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;
+ }
+ synchronized (serviceListeners) {
+ serviceListeners.clear();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java
new file mode 100644
index 0000000000..5b0b311d7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.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.osgi.service.discovery.impl;
+
+import static org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointListener.ENDPOINT_LISTENER_SCOPE;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+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.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.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointListener;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants;
+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.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 Map<String, List<EndpointListener>> filtersToListeners = new HashMap<String, List<EndpointListener>>();
+ // this is effectively a set which allows for multiple service descriptions with the
+ // same interface name but different properties and takes care of itself with respect to concurrency
+ protected Map<EndpointDescription, Bundle> servicesInfo = new ConcurrentHashMap<EndpointDescription, Bundle>();
+ private Map<EndpointListener, Collection<String>> listenersToFilters =
+ new HashMap<EndpointListener, Collection<String>>();
+ private ServiceTracker trackerTracker;
+
+ public AbstractDiscoveryService(BundleContext context) {
+ super();
+ this.context = context;
+ }
+
+ public void start() {
+ // 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.newInstance();
+ 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 synchronized void cacheTracker(ServiceReference reference, Object service) {
+ if (service instanceof EndpointListener) {
+ EndpointListener listener = (EndpointListener)service;
+ Collection<String> filters =
+ addTracker(reference, listener, ENDPOINT_LISTENER_SCOPE, filtersToListeners, listenersToFilters);
+
+ triggerCallbacks(null, filters, listener, true);
+ }
+ }
+
+ private synchronized void clearTracker(Object service) {
+ if (service instanceof EndpointListener) {
+ removeTracker((EndpointListener)service, filtersToListeners, listenersToFilters);
+ }
+ }
+
+ private synchronized void updateTracker(ServiceReference reference, Object service) {
+ if (service instanceof EndpointListener) {
+ EndpointListener listener = (EndpointListener)service;
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("updating listener: " + listener);
+ }
+ Collection<String> oldFilters = removeTracker(listener, filtersToListeners, listenersToFilters);
+
+ Collection<String> newFilters =
+ addTracker(reference, listener, ENDPOINT_LISTENER_SCOPE, filtersToListeners, listenersToFilters);
+
+ triggerCallbacks(oldFilters, newFilters, listener, true);
+ }
+ }
+
+ private void triggerCallbacks(Collection<String> oldInterest,
+ Collection<String> newInterest,
+ EndpointListener listener,
+ boolean isFilter) {
+ // compute delta between old & new interfaces/filters and
+ // trigger callbacks for any entries in servicesInfo that
+ // match any *additional* interface/filters
+ Collection<String> deltaInterest = new ArrayList<String>();
+ if (newInterest != null && !newInterest.isEmpty()) {
+ if (oldInterest == null || oldInterest.isEmpty()) {
+ deltaInterest.addAll(newInterest);
+ } else {
+ Iterator<String> i = newInterest.iterator();
+ while (i.hasNext()) {
+ String next = (String)i.next();
+ if (!oldInterest.contains(next)) {
+ deltaInterest.add(next);
+ }
+ }
+ }
+ }
+
+ if (logger.isLoggable(Level.FINE)) {
+ if (servicesInfo.size() > 0) {
+ logger.fine("search for matches to trigger callbacks with delta: " + deltaInterest);
+ } else {
+ logger.fine("nothing to search for matches to trigger callbacks with delta: " + deltaInterest);
+ }
+ }
+ Iterator<String> i = deltaInterest.iterator();
+ while (i.hasNext()) {
+ String next = i.next();
+ for (EndpointDescription sd : servicesInfo.keySet()) {
+ triggerCallbacks(listener, next, sd, ADDED);
+ }
+ }
+ }
+
+ private void triggerCallbacks(EndpointListener listener, String matchedFilter, EndpointDescription sd, int type) {
+ switch (type) {
+ case ADDED:
+ listener.endpointAdded(sd, matchedFilter);
+ break;
+ case REMOVED:
+ listener.endpointRemoved(sd, matchedFilter);
+ break;
+ case MODIFIED:
+ listener.endpointRemoved(sd, matchedFilter);
+ listener.endpointAdded(sd, matchedFilter);
+ break;
+ }
+ }
+
+ 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;
+ }
+
+ static Collection<String> removeTracker(EndpointListener listener,
+ Map<String, List<EndpointListener>> forwardMap,
+ Map<EndpointListener, Collection<String>> reverseMap) {
+ Collection<String> collection = reverseMap.get(listener);
+ if (collection != null && !collection.isEmpty()) {
+ reverseMap.remove(listener);
+ Iterator<String> i = collection.iterator();
+ while (i.hasNext()) {
+ String element = i.next();
+ if (forwardMap.containsKey(element)) {
+ forwardMap.get(element).remove(listener);
+ } else {
+ // if the element wasn't on the forwardmap, its a new element and
+ // shouldn't be returned as part of the collection of old ones
+ i.remove();
+ }
+ }
+ }
+ return collection;
+ }
+
+ @SuppressWarnings("unchecked")
+ static Collection<String> addTracker(ServiceReference reference,
+ EndpointListener listener,
+ String property,
+ Map<String, List<EndpointListener>> forwardMap,
+ Map<EndpointListener, Collection<String>> reverseMap) {
+ Collection<String> collection = OSGiHelper.getStringCollection(reference, property);
+ if (logger.isLoggable(Level.FINE)) {
+ logger.fine("adding listener: " + listener
+ + " collection: "
+ + collection
+ + " registered against prop: "
+ + property);
+ }
+ if (collection != null && !collection.isEmpty()) {
+ reverseMap.put(listener, new ArrayList<String>(collection));
+ Iterator<String> i = collection.iterator();
+ while (i.hasNext()) {
+ String element = i.next();
+ if (forwardMap.containsKey(element)) {
+ forwardMap.get(element).add(listener);
+ } else {
+ List<EndpointListener> trackerList = new ArrayList<EndpointListener>();
+ trackerList.add(listener);
+ forwardMap.put(element, trackerList);
+ }
+ }
+ }
+ return collection;
+ }
+
+ protected void endpointChanged(EndpointDescription sd, int type) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java
new file mode 100644
index 0000000000..bf70c98634
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.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.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.UtilityExtensionPoint;
+import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.EndpointDescription;
+import org.apache.tuscany.sca.runtime.DomainRegistryFactory;
+import org.apache.tuscany.sca.runtime.EndpointListener;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Discovery service based on the distributed SCA domain
+ */
+public class DomainDiscoveryService extends AbstractDiscoveryService implements EndpointListener {
+ private DomainRegistryFactory domainRegistryFactory;
+
+ public DomainDiscoveryService(BundleContext context) {
+ super(context);
+ }
+
+ public void start() {
+ super.start();
+ getExtensionPointRegistry();
+ this.domainRegistryFactory =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(DomainRegistryFactory.class);
+ domainRegistryFactory.addListener(this);
+ }
+
+ 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;
+ }
+
+ /*
+ if (!endpoint.isRemote()) {
+ Interface intf = endpoint.getService().getInterfaceContract().getInterface();
+ JavaInterface javaInterface = (JavaInterface)intf;
+ // String filter = getOSGiFilter(provider.getOSGiProperties(service));
+ // FIXME: What is the filter?
+ String filter = "(!(sca.reference=*))";
+ // "(sca.service=" + component.getURI() + "#service-name\\(" + service.getName() + "\\))";
+ ServiceReference ref = null;
+ try {
+ ref = bundleContext.getServiceReferences(javaInterface.getName(), filter)[0];
+ } catch (InvalidSyntaxException e) {
+ // Ignore
+ }
+ if (ref != null) {
+
+ }
+ } else
+ */
+ {
+ // Notify the endpoint listeners
+ EndpointDescription description = createEndpointDescription(bundleContext, endpoint);
+ endpointChanged(description, ADDED);
+ }
+ }
+
+ public void endpointRemoved(Endpoint endpoint) {
+ /*
+ if (!endpoint.isRemote()) {
+ // export services
+ } else
+ */
+ {
+ EndpointDescription description = createEndpointDescription(context, endpoint);
+ 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() {
+ domainRegistryFactory.removeListener(this);
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
new file mode 100644
index 0000000000..11dcd56272
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java
@@ -0,0 +1,205 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 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 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.EndpointDescription;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.RemoteConstants;
+import org.apache.tuscany.sca.osgi.remoteserviceadmin.impl.OSGiHelper;
+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.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();
+ getExtensionPointRegistry();
+
+ 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(RemoteConstants.SERVICE_REMOTE_ID)) {
+ props.put(RemoteConstants.SERVICE_REMOTE_ID, String.valueOf(System.currentTimeMillis()));
+ }
+ if (!props.containsKey(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID)) {
+ props.put(RemoteConstants.SERVICE_REMOTE_FRAMEWORK_UUID, OSGiHelper.getFrameworkUUID(context));
+ }
+ if (!props.containsKey(RemoteConstants.SERVICE_REMOTE_URI)) {
+ props.put(RemoteConstants.SERVICE_REMOTE_URI, UUID.randomUUID().toString());
+ }
+
+ EndpointDescription sed = new EndpointDescription(props);
+ return sed;
+ }
+
+ private void removeServicesDeclaredInBundle(Bundle bundle) {
+ for (Iterator<Map.Entry<EndpointDescription, Bundle>> i = servicesInfo.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) {
+ 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);
+ }
+ }
+
+ // Notify
+ for (ServiceDescriptions sds : extender.getRemoteServiceDescriptions()) {
+ for (ServiceDescription sd : sds) {
+ EndpointDescription sed = createEndpointDescription(sd);
+ servicesInfo.put(sed, bundle);
+ serviceDescriptionAdded(sed);
+ }
+ }
+
+ this.extenders.add(extender);
+ 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;
+ }
+
+ }
+
+ @Override
+ protected Dictionary<String, Object> getProperties() {
+ Dictionary<String, Object> props = super.getProperties();
+ props.put(SUPPORTED_PROTOCOLS, new String[] {"local"});
+ return props;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..cf1b78931a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..0960938086
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..5348d19f34
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..268f16bc9f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java
new file mode 100644
index 0000000000..2af5552279
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
new file mode 100644
index 0000000000..619dcaa07d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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();
+ }
+
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..4b7b7ec71b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b14b3516f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml
new file mode 100644
index 0000000000..0dc812c503
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.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.
+-->
+<!-- A consumer-side service description file for RFC 119 -->
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+ <!-- Describe a remote OSGi service -->
+ <service-description>
+ <provide interface="calculator.dosgi.operations.AddService" />
+ <property name="service.intents">sca:SOAP sca:HTTP</property>
+ <property name="osgi.remote.configuration.type">org.osgi.sca</property>
+ <property name="osgi.remote.configuration.sca.componentType">
+ OSGI-INF/sca/bundle.componentType
+ </property>
+ <property name="osgi.remote.configuration.sca.reference">
+ addService
+ </property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.SubtractService" />
+ <property name="service.intents">sca:SOAP sca:HTTP</property>
+ <property name="osgi.remote.configuration.type">org.osgi.sca</property>
+ <property name="osgi.remote.configuration.sca.componentType">
+ OSGI-INF/sca/bundle.componentType
+ </property>
+ <property name="osgi.remote.configuration.sca.reference">
+ subtractService
+ </property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.MultiplyService" />
+ <property name="service.intents">sca:SOAP sca:HTTP</property>
+ <property name="osgi.remote.configuration.type">org.osgi.sca</property>
+ <property name="osgi.remote.configuration.sca.componentType">
+ OSGI-INF/sca/bundle.componentType
+ </property>
+ <property name="osgi.remote.configuration.sca.reference">
+ multiplyService
+ </property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.DivideService" />
+ <property name="service.intents">sca:SOAP sca:HTTP</property>
+ <property name="osgi.remote.configuration.type">org.osgi.sca</property>
+ <property name="osgi.remote.configuration.sca.componentType">
+ OSGI-INF/sca/bundle.componentType
+ </property>
+ <property name="osgi.remote.configuration.sca.reference">
+ divideService
+ </property>
+ </service-description>
+</service-descriptions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType
new file mode 100644
index 0000000000..bc9e4f6aaf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/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/200903"
+ 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 -->
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite
new file mode 100644
index 0000000000..1ae44d0a0b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2345c785a7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..16a33f4f65
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:OperationsComposite" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType
new file mode 100644
index 0000000000..72e2c339f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType
@@ -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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="SubtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="MultiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="DivideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite
new file mode 100644
index 0000000000..253f7d0df1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..60dc54014a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b14b3516f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite b/tags/java/sca/2.0-M4-RC2/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite
new file mode 100644
index 0000000000..43f101e799
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/node-impl/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-impl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cd4afe6871
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/META-INF/MANIFEST.MF
@@ -0,0 +1,42 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node.impl;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Node Implementation
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397240796
+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/tags/java/sca/2.0-M4-RC2/modules/node-impl/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/node-impl/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl/pom.xml
new file mode 100644
index 0000000000..d85558441b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-deployment</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-builder</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-sca-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-databinding</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xsd</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java
new file mode 100644
index 0000000000..78f4fabb20
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.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.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/200903";
+ 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;
+ }
+ writeStart(writer,
+ BINDING.getNamespaceURI(),
+ BINDING.getLocalPart(),
+ new XAttr("name", b.getBindingType()),
+ new XAttr("baseURIs", uris.toString()));
+ writeEnd(writer);
+ }
+
+ for(Object o: node.getExtensions()) {
+ processor.write(o, writer, context);
+ }
+
+ writeEnd(writer);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java
new file mode 100644
index 0000000000..604bb502f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.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.node.impl;
+
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.CompositeContext;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class CompositeContextImpl extends CompositeContext {
+ private final ExtensionPointRegistry extensionPointRegistry;
+ private final EndpointRegistry endpointRegistry;
+ private final ComponentContextFactory componentContextFactory;
+ private final Composite domainComposite;
+
+ public CompositeContextImpl(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry, Composite domainComposite) {
+ this.extensionPointRegistry = registry;
+ this.endpointRegistry = endpointRegistry;
+ ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
+ this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
+ this.domainComposite = domainComposite;
+ }
+
+ public ExtensionPointRegistry getExtensionPointRegistry() {
+ return extensionPointRegistry;
+ }
+
+ public EndpointRegistry getEndpointRegistry() {
+ return endpointRegistry;
+ }
+
+ public void bindComponent(RuntimeComponent runtimeComponent) {
+ RuntimeComponentContext componentContext =
+ (RuntimeComponentContext)componentContextFactory.createComponentContext(this, runtimeComponent);
+ runtimeComponent.setComponentContext(componentContext);
+ }
+
+ public void bindEndpointReference(EndpointReference endpointReference) {
+
+ }
+
+ public Composite getDomainComposite() {
+ return domainComposite;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
new file mode 100644
index 0000000000..e4e2386667
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java
@@ -0,0 +1,398 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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.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.core.invocation.ProxyFactoryExtensionPoint;
+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.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.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) {
+ 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;
+ }
+
+ protected Object getNodeKey(NodeConfiguration configuration) {
+ return new NodeKey(configuration);
+ }
+
+ public synchronized void destroy() {
+ if (inited) {
+ for (Node node : nodes.values()) {
+ node.stop();
+ node.destroy();
+ }
+ 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 getExtensionPoints() {
+ return registry;
+ }
+
+ public synchronized void init() {
+ if (inited) {
+ return;
+ }
+ long start = currentTimeMillis();
+
+ if (registry == null) {
+ // Create extension point registry
+ registry = createExtensionPointRegistry();
+ registry.start();
+ }
+
+ // Use the runtime-enabled assembly factory
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ AssemblyFactory assemblyFactory = new RuntimeAssemblyFactory(registry);
+ modelFactories.addFactory(assemblyFactory);
+
+ UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
+ monitorFactory = utilities.getUtility(MonitorFactory.class);
+
+ // 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
+ ProxyFactoryExtensionPoint proxyFactories = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ proxyFactory = new ExtensibleProxyFactory(proxyFactories);
+
+ utilities.getUtility(WorkScheduler.class);
+
+ inited = true;
+
+ if (logger.isLoggable(Level.FINE)) {
+ long end = currentTimeMillis();
+ logger.fine("The tuscany runtime started in " + (end - start) + " ms.");
+ }
+ }
+
+ 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());
+ }
+ Composite domainComposite = deployer.build(contributions, bindingBaseURIs, monitor);
+ analyzeProblems(monitor);
+
+ return domainComposite;
+ }
+
+ 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();
+ }
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
new file mode 100644
index 0000000000..4be947f125
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -0,0 +1,369 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+//import javax.management.MBeanServer;
+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.common.java.io.IOHelper;
+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.Client;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFinder;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.management.NodeManager;
+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.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, Client {
+ 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 manager;
+ private List<Contribution> contributions;
+ private NodeManager mbean;
+
+ /**
+ * Create a node from the configuration
+ * @param manager
+ * @param configuration
+ */
+ public NodeImpl(NodeFactoryImpl manager, NodeConfiguration configuration) {
+ super();
+ this.configuration = configuration;
+ this.manager = manager;
+ }
+
+ /**
+ * 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.manager = manager;
+ this.contributions = new ArrayList<Contribution>(contributions);
+ }
+
+ public String getURI() {
+ return getConfiguration().getURI();
+ }
+
+ public void destroy() {
+ }
+
+ public Node start() {
+ logger.log(Level.INFO, "Starting node: " + configuration.getURI() + " domain: " + configuration.getDomainName());
+
+ manager.init();
+ manager.addNode(configuration, this);
+ this.proxyFactory = manager.proxyFactory;
+ UtilityExtensionPoint utilities = manager.registry.getExtensionPoint(UtilityExtensionPoint.class);
+
+ DomainRegistryFactory domainRegistryFactory = utilities.getUtility(DomainRegistryFactory.class);
+ EndpointRegistry endpointRegistry =
+ domainRegistryFactory.getEndpointRegistry(configuration.getDomainRegistryURI(), configuration
+ .getDomainURI());
+
+ this.compositeActivator = utilities.getUtility(CompositeActivator.class);
+ try {
+ Monitor monitor = manager.monitorFactory.createMonitor();
+ ProcessorContext context = new ProcessorContext(monitor);
+
+ // Set up the thead context monitor
+ Monitor tcm = manager.monitorFactory.setContextMonitor(monitor);
+ try {
+ if (contributions == null) {
+ contributions = manager.loadContributions(configuration, context);
+ }
+ domainComposite = manager.configureNode(configuration, contributions, context);
+
+ this.compositeContext =
+ new CompositeContextImpl(manager.registry, endpointRegistry, domainComposite);
+ } finally {
+ // Reset the thread context monitor
+ manager.monitorFactory.setContextMonitor(tcm);
+ }
+
+ // Activate the composite
+ compositeActivator.activate(compositeContext, domainComposite);
+
+ // Start the composite
+ compositeActivator.start(compositeContext, domainComposite);
+
+ NodeFinder.addNode(IOHelper.createURI(configuration.getDomainURI()), this);
+
+ // 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;
+ }
+ }
+ */
+
+ NodeFinder.removeNode(this);
+ if( domainComposite != null ) {
+
+ // Stop the composite
+ compositeActivator.stop(compositeContext, domainComposite);
+
+ // Deactivate the composite
+ compositeActivator.deactivate(domainComposite);
+
+ } // end if
+
+ manager.removeNode(configuration);
+ manager.registry.getExtensionPoint(UtilityExtensionPoint.class).removeUtility(compositeActivator);
+ this.compositeActivator = null;
+ this.proxyFactory = null;
+ this.domainComposite = null;
+ this.compositeContext = null;
+
+ ThreadMessageContext.removeMessageContext();
+
+ } 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;
+ }
+ }
+
+ 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()) {
+ if (serviceName == null || serviceName.equals(componentService.getName())) {
+ CompositeService compositeService = (CompositeService)componentService.getService();
+ if (compositeService != null) {
+ componentContext =
+ ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
+ return componentContext.createSelfReference(businessInterface, compositeService
+ .getPromotedService());
+ }
+ 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 getExtensionPoints() {
+ return manager.getExtensionPoints();
+ }
+
+ /**
+ * 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 =
+ getExtensionPoints().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 =
+ manager.getExtensionPoints().getExtensionPoint(FactoryExtensionPoint.class)
+ .getFactory(XMLOutputFactory.class);
+
+ try {
+ compositeProcessor.write(composite, outputFactory.createXMLStreamWriter(bos), new ProcessorContext(manager.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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java
new file mode 100644
index 0000000000..4da41442f5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java
new file mode 100644
index 0000000000..12704a3ee5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java
new file mode 100644
index 0000000000..3133142c2b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorld.java
new file mode 100644
index 0000000000..e3fcdfd25f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/hello/HelloWorldImpl.java
new file mode 100644
index 0000000000..c9a7560b12
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java
new file mode 100644
index 0000000000..aa7933630a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.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.node.impl;
+
+import hello.HelloWorld;
+
+import java.io.File;
+import java.io.StringReader;
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+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/200903\"" + " 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 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();
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java
new file mode 100644
index 0000000000..5a47465702
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.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.node.impl;
+
+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());
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/HelloWorld.composite
new file mode 100644
index 0000000000..efe43cbf2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..1149eb5cbf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sc="http://sample/composite">
+ <deployable composite="sc:HelloWorld" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/tags/java/sca/2.0-M4-RC2/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml
new file mode 100644
index 0000000000..5b2835c434
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/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"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..359daed2cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/META-INF/MANIFEST.MF
@@ -0,0 +1,23 @@
+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
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Node Equinox OSGi Launcher
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397473703
+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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/pom.xml
new file mode 100644
index 0000000000..db366253ce
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-http-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency-->
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
new file mode 100644
index 0000000000..fd4d0ee5bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java
@@ -0,0 +1,655 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.");
+ }
+ 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")) {
+ 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) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
new file mode 100644
index 0000000000..79aedc81c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java
@@ -0,0 +1,376 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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);
+ 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
+ }
+ }
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
new file mode 100644
index 0000000000..939372d782
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java
@@ -0,0 +1,1345 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 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 (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
+ 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;
+ }
+
+ // 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 jars - since the development versions of these are used
+ // from the \target\classes directories...
+ if (name.startsWith("tuscany")) {
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF b/tags/java/sca/2.0-M4-RC2/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..400fdc58e8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF
@@ -0,0 +1,48 @@
+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
+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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF b/tags/java/sca/2.0-M4-RC2/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..b3e9d79d28
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java
new file mode 100644
index 0000000000..e3fcdfd25f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java
new file mode 100644
index 0000000000..8232acb658
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java
new file mode 100644
index 0000000000..e51d3c79d9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite b/tags/java/sca/2.0-M4-RC2/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite
new file mode 100644
index 0000000000..ccd116e848
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..ef73723b48
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.node.launcher;uses:="javax.serv
+ let";version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Node Launcher
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397407125
+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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/pom.xml
new file mode 100644
index 0000000000..dfd52904cc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java
new file mode 100644
index 0000000000..4f4f861e2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java
new file mode 100644
index 0000000000..ba795216a9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java
new file mode 100644
index 0000000000..39e8d81139
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java
new file mode 100644
index 0000000000..56be9f9921
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java
new file mode 100644
index 0000000000..d8df30377b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.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.node.launcher;
+
+import static org.apache.tuscany.sca.node.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;
+
+/**
+ * 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");
+ // opt4.setType(long.class);
+ options.addOption(opt3);
+ 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>]"
+ + " [-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.");
+
+ // 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);
+ }
+ }
+ }
+
+ /**
+ * 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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java
new file mode 100644
index 0000000000..38dea77eda
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java
new file mode 100644
index 0000000000..77751dcc47
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java b/tags/java/sca/2.0-M4-RC2/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java
new file mode 100644
index 0000000000..5345363031
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f25e5d43d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/META-INF/MANIFEST.MF
@@ -0,0 +1,30 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany Logging Policy Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397480671
+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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/pom.xml
new file mode 100644
index 0000000000..ea6b25c37f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-logging</artifactId>
+ <name>Apache Tuscany Logging Policy Model</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java
new file mode 100644
index 0000000000..4bed9520ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java
new file mode 100644
index 0000000000..be9a05982f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.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.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 void build(Endpoint endpoint, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpoint);
+ System.out.println(endpoint + ": " + polices);
+ }
+
+ public void build(EndpointReference endpointReference, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(endpointReference);
+ System.out.println(endpointReference + ": " + polices);
+ }
+
+ public void build(Component component, Implementation implementation, BuilderContext context) {
+ List<JDKLoggingPolicy> polices = getPolicies(implementation);
+ System.out.println(implementation + ": " + polices);
+ }
+
+ public QName getPolicyType() {
+ return JDKLoggingPolicy.JDK_LOGGING_POLICY_QNAME;
+ }
+
+ 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;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java
new file mode 100644
index 0000000000..0c20d1fa84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.0/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java
new file mode 100644
index 0000000000..6ca5732e7a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.getBoolean(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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml
new file mode 100644
index 0000000000..95c976ba49
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/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/200903"
+ targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1">
+
+ <!-- Policy Intents Defined by the SCA Runtime -->
+ <intent name="logging" constrains="implementation binding">
+ <description>
+ All messages to and from this implementation must be logged
+ </description>
+ </intent>
+
+</definitions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/policy-security/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/policy-security/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2a4e4b3205
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/META-INF/MANIFEST.MF
@@ -0,0 +1,64 @@
+Manifest-Version: 1.0
+Export-Package: org.apache.tuscany.sca.policy.authorization;uses:="jav
+ ax.xml.stream,org.apache.tuscany.sca.contribution.resolver,org.apache
+ .tuscany.sca.contribution.processor,org.apache.tuscany.sca.core,org.a
+ pache.tuscany.sca.monitor,org.apache.tuscany.sca.policy,javax.xml.nam
+ espace";version="2.0.0",org.apache.tuscany.sca.policy.security.jaas;use
+ s:="javax.security.auth.callback,org.apache.tuscany.sca.runtime,org.a
+ pache.tuscany.sca.assembly,org.apache.tuscany.sca.provider,javax.secu
+ rity.auth.login,org.apache.tuscany.sca.core,org.apache.tuscany.sca.mo
+ nitor,org.apache.tuscany.sca.policy,org.apache.tuscany.sca.interfaced
+ ef,javax.xml.namespace,org.apache.tuscany.sca.invocation,javax.xml.st
+ ream,org.apache.tuscany.sca.contribution.resolver,org.apache.tuscany.
+ sca.policy.util,org.apache.tuscany.sca.contribution.processor,org.oasisopen
+ .sca";version="2.0.0",org.apache.tuscany.sca.policy.authentication.bas
+ ic;uses:="org.apache.tuscany.sca.runtime,org.apache.tuscany.sca.assem
+ bly,org.apache.tuscany.sca.provider,org.apache.tuscany.sca.core,org.a
+ pache.tuscany.sca.policy,org.apache.tuscany.sca.monitor,org.apache.tu
+ scany.sca.interfacedef,javax.xml.namespace,org.apache.tuscany.sca.inv
+ ocation,javax.xml.stream,org.apache.tuscany.sca.contribution.resolver
+ ,org.apache.tuscany.sca.contribution.processor";version="2.0.0",org.apa
+ che.tuscany.sca.policy.security;uses:="org.apache.tuscany.sca.definit
+ ions.util,org.apache.tuscany.sca.provider,org.apache.tuscany.sca.defi
+ nitions,org.apache.tuscany.sca.contribution.processor,org.apache.tusc
+ any.sca.core";version="2.0.0",org.apache.tuscany.sca.policy.identity;us
+ es:="javax.xml.stream,org.apache.tuscany.sca.contribution.resolver,or
+ g.apache.tuscany.sca.contribution.processor,org.apache.tuscany.sca.co
+ re,org.apache.tuscany.sca.monitor,org.apache.tuscany.sca.policy,javax
+ .xml.namespace";version="2.0.0",org.apache.tuscany.sca.policy.authentic
+ ation.token;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany Security Policy Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397295515
+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/tags/java/sca/2.0-M4-RC2/modules/policy-security/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/policy-security/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-security/pom.xml
new file mode 100644
index 0000000000..0f45ef1ec6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java
new file mode 100644
index 0000000000..9b894101ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.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.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.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);
+ }
+
+ /**
+ * @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 BasicAuthenticationServicePolicyProvider(endpoint);
+ }
+
+ public Class<BasicAuthenticationPolicy> getModelType() {
+ return BasicAuthenticationPolicy.class;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java
new file mode 100644
index 0000000000..189866a23f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.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.policy.authentication.basic;
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+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.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.security.SecurityUtil;
+
+/**
+ *
+ * @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 Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationReferencePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ // get the security context
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject,
+ BasicAuthenticationPrincipal.class);
+
+ // if no credentials propogated from the reference then use
+ // the ones from the policy
+ if (principal == null &&
+ policy.getUserName() != null &&
+ !policy.getUserName().equals("")) {
+ principal = new BasicAuthenticationPrincipal(policy.getUserName(),
+ policy.getPassword());
+ subject.getPrincipals().add(principal);
+ }
+
+ if (principal == null){
+ // alternatively we could call out here to some 3rd party system to get credentials
+ // or convert from some other security principal
+ }
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.REFERENCE_POLICY;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java
new file mode 100644
index 0000000000..d4d8e59429
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.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.authentication.basic;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationReferencePolicyProvider implements PolicyProvider {
+ private EndpointReference endpointReference;
+
+ public BasicAuthenticationReferencePolicyProvider(EndpointReference endpointReference) {
+ super();
+ this.endpointReference = endpointReference;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpointReference.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (BasicAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpointReference.getURI();
+ }
+
+ /**
+ * @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 BasicAuthenticationReferencePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java
new file mode 100644
index 0000000000..39f70c7e78
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.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.policy.authentication.basic;
+
+
+import javax.security.auth.Subject;
+import javax.xml.namespace.QName;
+
+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.Phase;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.PolicySet;
+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 Operation operation;
+ private PolicySet policySet = null;
+ private String context;
+ private BasicAuthenticationPolicy policy;
+
+ public BasicAuthenticationServicePolicyInterceptor(String context, Operation operation, PolicySet policySet) {
+ super();
+ this.operation = operation;
+ this.policySet = policySet;
+ this.context = context;
+ init();
+ }
+
+ private void init() {
+ if (policySet != null) {
+ for (Object policyObject : policySet.getPolicies()){
+ if (policyObject instanceof BasicAuthenticationPolicy){
+ policy = (BasicAuthenticationPolicy)policyObject;
+ break;
+ }
+ }
+ }
+ }
+
+ public Message invoke(Message msg) {
+
+ Subject subject = SecurityUtil.getSubject(msg);
+ BasicAuthenticationPrincipal principal = SecurityUtil.getPrincipal(subject,
+ BasicAuthenticationPrincipal.class);
+
+ if (principal != null){
+
+ System.out.println("Username: " +
+ principal.getName() +
+ " Password: " +
+ principal.getPassword());
+
+ // could call out here to some 3rd party system to do whatever you
+ // need to do do with username and password
+
+ }
+
+ return getNext().invoke(msg);
+ }
+
+ public Invoker getNext() {
+ return next;
+ }
+
+ public void setNext(Invoker next) {
+ this.next = next;
+ }
+
+ public String getPhase() {
+ return Phase.SERVICE_POLICY;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java
new file mode 100644
index 0000000000..b640ec60e5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.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.authentication.basic;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+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.PolicyProvider;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BasicAuthenticationServicePolicyProvider implements PolicyProvider {
+ private Endpoint endpoint;
+
+ public BasicAuthenticationServicePolicyProvider(Endpoint endpoint) {
+ super();
+ this.endpoint = endpoint;
+ }
+
+ private PolicySet findPolicySet() {
+ List<PolicySet> policySets = endpoint.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (BasicAuthenticationPolicy.class.isInstance(p)) {
+ return ps;
+ }
+ }
+ }
+ return null;
+ }
+
+ private String getContext() {
+ return endpoint.getURI();
+ }
+
+ /**
+ * @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 BasicAuthenticationServicePolicyInterceptor(getContext(), operation, ps);
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java
new file mode 100644
index 0000000000..147b863c01
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.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.authentication.token;
+
+import java.security.Principal;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java
new file mode 100644
index 0000000000..8b0bbd54ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ // 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java
new file mode 100644
index 0000000000..8a65a10560
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java
new file mode 100644
index 0000000000..773c874a90
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java
new file mode 100644
index 0000000000..2783a37316
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityImplementationPolicyProvider implements PolicyProvider {
+ private RuntimeComponent component;
+ private Implementation implementation;
+
+ public SecurityIdentityImplementationPolicyProvider(RuntimeComponent component) {
+ super();
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java
new file mode 100644
index 0000000000..28ffcaf348
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.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.identity;
+
+import javax.xml.namespace.QName;
+
+/**
+ * Models the SCA Implementation Security Policy Assertion for Security Identity.
+ *
+ * @version $Rev$ $Date$
+ */
+public class SecurityIdentityPolicy {
+ private final static String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ public static final QName NAME = new QName(SCA11_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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java
new file mode 100644
index 0000000000..3c91b9fbcf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java
new file mode 100644
index 0000000000..80e1494796
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java
new file mode 100644
index 0000000000..1297b44b93
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.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.security;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.apache.tuscany.sca.invocation.Message;
+
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class SecurityUtil {
+
+ public static Subject getSubject(Message msg){
+
+ Subject subject = null;
+
+ for (Object header : msg.getHeaders()){
+ if (header instanceof Subject){
+ subject = (Subject)header;
+ break;
+ }
+ }
+
+ if (subject == null){
+ subject = new Subject();
+ msg.getHeaders().add(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){
+
+ Principal principal = null;
+
+ for (Object header : msg.getHeaders()){
+ if (header instanceof Principal){
+ principal = (Principal)header;
+ break;
+ }
+ }
+
+ return principal;
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java
new file mode 100644
index 0000000000..6666469b75
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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.PolicyProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Policy handler to handle PolicySet containing JaasAuthenticationPolicy instances
+ *
+ * @version $Rev$ $Date$
+ */
+public class JaasAuthenticationImplementationPolicyProvider implements PolicyProvider {
+ private RuntimeComponent component;
+ private Implementation implementation;
+
+ public JaasAuthenticationImplementationPolicyProvider(RuntimeComponent component) {
+ super();
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..cb284822ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
@@ -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.
+
+# Implementation class for the artifact processor extension
+org.apache.tuscany.sca.policy.authorization.AuthorizationPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#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/200903#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/200903#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/200903#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/200903#runAs,model=org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy
+org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProcessor;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#securityIdentity,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
+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
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
new file mode 100644
index 0000000000..d3d8f8e38a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory
@@ -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 policy extension
+org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.security.jaas.JaasAuthenticationPolicy
+org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicyProviderFactory;model=org.apache.tuscany.sca.policy.authentication.basic.BasicAuthenticationPolicy
+org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicyProviderFactory;model=org.apache.tuscany.sca.policy.identity.SecurityIdentityPolicy
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml
new file mode 100644
index 0000000000..9a02731e8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml
new file mode 100644
index 0000000000..f3af5bc964
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903" 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/policy-security-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/policy-security-validation-messages.properties
new file mode 100644
index 0000000000..ebb47f2b60
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/main/resources/policy-security-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.
+#
+#
+RequiredAttributeRolesMissing = Required attribute 'roles' is missing.
+ClassNotFoundException = Class Not Found Exception: {0} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java
new file mode 100644
index 0000000000..0d8a5d5a9c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903";
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml
new file mode 100644
index 0000000000..acb47de243
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml
@@ -0,0 +1,78 @@
+<?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/200903" targetNamespace="http://tuscany.apache.org/xmlns/sca/1.1"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+ <!-- 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">
+ <securityIdentity>
+ <runAs role="admin" />
+ </securityIdentity>
+ </policySet>
+
+ <!-- POLICY SETS -->
+ <policySet name="ps5" provides="securityIdentity" appliesTo="sca:implementation">
+ <securityIdentity>
+ <useCallerIdentity />
+ </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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..a143352a90
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Private-Package: org.apache.tuscany.sca.policy.xml.ws;version="2.0.0"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Policy XML WS Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397120421
+Bundle-ManifestVersion: 2
+Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
+Bundle-Description: Apache Tuscany SCA Policy XML WS Model
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ org.apache.axiom.om,
+ org.apache.neethi,
+ 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";resolution:=optional,
+ org.apache.tuscany.sca.policy.xml;version="2.0.0";resolution:=optional
+Bundle-SymbolicName: org.apache.tuscany.sca.policy.xml.ws
+Bundle-DocURL: http://www.apache.org/
+Export-Package: org.apache.tuscany.sca.policy.xml.ws;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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/pom.xml
new file mode 100644
index 0000000000..58070155e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-policy-xml-ws</artifactId>
+ <name>Apache Tuscany SCA Policy XML WS Model</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-assembly-xml</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ <version>1.2.7</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.7</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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessor.java
new file mode 100644
index 0000000000..760ce7c8da
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessor.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.policy.xml.ws;
+
+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.axiom.om.OMNamespace;
+import org.apache.neethi.PolicyEngine;
+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;
+
+
+/**
+ * Processor for handling xml models of PolicySet definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public class WSPolicyProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<org.apache.neethi.Policy> {
+ 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);
+
+ public WSPolicyProcessor() {
+ }
+
+ public WSPolicyProcessor(FactoryExtensionPoint modelFactories) {
+ }
+
+ public QName getArtifactType() {
+ return WS_POLICY_QNAME;
+ }
+
+ public Class<org.apache.neethi.Policy> getModelType() {
+ return org.apache.neethi.Policy.class;
+ }
+
+ public org.apache.neethi.Policy read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ org.apache.neethi.Policy wsPolicy = null;
+
+ int event = reader.getEventType();
+ if (event == START_ELEMENT) {
+ QName name = reader.getName();
+ if (WS_POLICY_QNAME.equals(name)) {
+ OMElement policyElement = loadElement(reader);
+ wsPolicy = PolicyEngine.getPolicy(policyElement);
+ }
+ }
+ return wsPolicy;
+ }
+
+ public void write(org.apache.neethi.Policy wsPolicy, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+
+ // Write an <sca:policySet>
+ writer.writeStartElement(WS_POLICY_NS, WS_POLICY);
+
+ //FIXME write proper ws-policy stuff here
+
+ writer.writeEndElement();
+ }
+
+ public void resolve(org.apache.neethi.Policy wsPolicy, ModelResolver resolver, 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:
+ QName name = reader.getName();
+ 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++) {
+ OMNamespace omNs = null;
+ String ns = reader.getAttributeNamespace(i);
+ String prefix = reader.getAttributePrefix(i);
+ String qname = reader.getAttributeLocalName(i);
+ String value = reader.getAttributeValue(i);
+
+ if ( ns != null ) {
+ omNs = fac.createOMNamespace(ns, prefix);
+ }
+
+ child.addAttribute(qname, value, omNs);
+ if (ns != null) {
+ child.declareNamespace(ns, prefix);
+ }
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
new file mode 100644
index 0000000000..0ef04d5e41
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-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.policy.xml.ws.WSPolicyProcessor;qname=http://schemas.xmlsoap.org/ws/2004/09/policy#Policy,model=org.apache.neethi.Policy
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestModelResolver.java
new file mode 100644
index 0000000000..8e904615c8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/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.xml.ws;
+
+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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java
new file mode 100644
index 0000000000..954ae00d42
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.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.xml.ws;
+
+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;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestPolicyProcessor implements StAXArtifactProcessor<Object> {
+
+ public QName getArtifactType() {
+ return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment");
+ }
+
+ public Object read(XMLStreamReader arg0, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ return new MockPolicyImplOne();
+ }
+
+ public void write(Object arg0, XMLStreamWriter arg1, ProcessorContext context) throws ContributionWriteException,
+ XMLStreamException {
+ }
+
+ public Class<Object> getModelType() {
+ // TODO Auto-generated method stub
+ return Object.class;
+ }
+
+ public void resolve(Object arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException {
+
+ }
+
+
+ public class MockPolicyImplOne {
+ public QName getSchemaName() {
+ 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/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessorTestCase.java
new file mode 100644
index 0000000000..47cf0e5c2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessorTestCase.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.policy.xml.ws;
+
+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.XMLStreamReader;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+
+/**
+ * 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/200903\""
+ + " targetNamespace=\"http://test\""
+ + " xmlns:test=\"http://test\""
+ + " xmlns:sca=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\">"
+ + " "
+ + " <policySet name=\"SecureWSPolicy\""
+ + " provides=\"test:confidentiality\""
+ + " appliesTo=\"sca:binding.ws\""
+ + " xmlns=\"http://docs.oasis-open.org/ns/opencsa/sca/200903\""
+ + " 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));
+ WSPolicyProcessor processor = new WSPolicyProcessor();
+ Object artifact = null;
+
+ QName name = null;
+ reader.next();
+ while ( true ) {
+ int event = reader.getEventType();
+ switch (event) {
+ case START_ELEMENT: {
+ name = reader.getName();
+
+ if(WSPolicyProcessor.WS_POLICY_QNAME.equals(name)) {
+ artifact = processor.read(reader, new ProcessorContext());
+ }
+
+ break;
+ }
+ }
+
+ if ( reader.hasNext() ) {
+ reader.next();
+ } else {
+ break;
+ }
+ }
+ assertNotNull(artifact);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
new file mode 100644
index 0000000000..a2e321068f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -0,0 +1,106 @@
+<?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/200903"
+ targetNamespace="http://test"
+ xmlns:test="http://test"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903">
+
+<policySet name="SecureWSPolicy"
+ provides="test:confidentiality"
+ appliesTo="sca:binding.ws"
+ xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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>
+ </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/tags/java/sca/2.0-M4-RC2/modules/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/pom.xml
new file mode 100644
index 0000000000..16be25e0f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/pom.xml
@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</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-runtime</module>
+ <module>binding-ejb</module>
+ <module>binding-ejb-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-runtime</module>
+ <module>binding-rmi</module>
+ <module>binding-rmi-runtime</module>
+ <module>binding-sca-runtime</module>
+ <module>binding-sca-axis2-runtime</module>
+ <module>binding-ws</module>
+ <module>binding-ws-axis2</module>
+ <module>binding-ws-axis2-policy</module>
+ <module>binding-ws-wsdlgen</module>
+ <module>builder</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-json</module>
+ <module>deployment</module>
+ <module>domain-node</module>
+ <module>endpoint-tribes</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-spring</module>
+ <module>implementation-spring-sca</module>
+ <module>implementation-web</module>
+ <module>implementation-web-client</module>
+ <module>implementation-web-runtime</module>
+ <module>interface-java</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-xml-ws</module>
+ <module>policy-logging</module>
+ <module>sca-api</module>
+ <module>sca-client-impl</module>
+ <module>stripes</module>
+ <module>xsd</module>
+ <!-- OSGi Remote Services with SCA -->
+ <module>contribution-osgi</module>
+ <module>implementation-osgi</module>
+ <module>implementation-osgi-runtime</module>
+ <module>node-impl-osgi</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.4</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.5</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/tags/java/sca/2.0-M4-RC2/modules/sca-api/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/sca-api/LICENSE
new file mode 100644
index 0000000000..617c69079b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/LICENSE
@@ -0,0 +1,243 @@
+
+ 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 sca-api includes a number of 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/tags/java/sca/2.0-M4-RC2/modules/sca-api/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/sca-api/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..2120e72d06
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA API
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397105046
+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/tags/java/sca/2.0-M4-RC2/modules/sca-api/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/sca-api/NOTICE
new file mode 100644
index 0000000000..12fdd031e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/NOTICE
@@ -0,0 +1,13 @@
+${pom.name}
+Copyright (c) 2005 - 2009 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,
+37 Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase
+38 Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/sca-api/pom.xml
new file mode 100644
index 0000000000..49cfd31274
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java
new file mode 100644
index 0000000000..5ba145ce49
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java
@@ -0,0 +1,122 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+import java.util.Collection;
+
+/**
+ * Interface providing programmatic access to a component's SCA context as an alternative to injection.
+ * It provides access to reference and property values for the component and provides a mechanism for
+ * obtaining a reference to a service that can be passed to other components.
+ * <p/>
+ * SCA components obtain an instance of this interface through injection. Non-SCA client code may also
+ * obtain an instance through runtime-specific mechanisms.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface ComponentContext {
+ /**
+ * Returns the absolute URI of the component within the SCA Domain.
+ *
+ * @return the absolute URI of the component
+ */
+ String getURI();
+
+ /**
+ * 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 reference defined by this component.
+ *
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param referenceName the name of the reference
+ * @param <B> the Java type of the business interface for the reference
+ * @return an object that implements the business interface
+ */
+ <B> B getService(Class<B> businessInterface, String referenceName);
+
+ /**
+ * Returns a ServiceReference for a reference defined by this component.
+ *
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param referenceName the name of the reference
+ * @param <B> the Java type of the business interface for the reference
+ * @return a ServiceReference for the designated reference
+ */
+ <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String referenceName);
+
+ /**
+ * Returns the value of an SCA property defined by this component.
+ *
+ * @param type the Java type to be returned for the property
+ * @param propertyName the name of the property whose value should be returned
+ * @param <B> the Java type of the property
+ * @return the property value
+ */
+ <B> B getProperty(Class<B> type, String propertyName);
+
+ /**
+ * Returns a ServiceReference that can be used to invoke this component over the default service.
+ *
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param <B> the Java type of the business interface for the reference
+ * @return a ServiceReference that will invoke this component
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface);
+
+ /**
+ * Returns a ServiceReference that can be used to invoke this component over the designated service.
+ *
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param serviceName the name of the service to invoke
+ * @param <B> the Java type of the business interface for the reference
+ * @return a ServiceReference that will invoke this component
+ */
+ <B> ServiceReference<B> createSelfReference(Class<B> businessInterface, String serviceName);
+
+ /**
+ * Returns the context for the current SCA service request, or null if there is no current request
+ * or if the context is unavailable.
+ *
+ * @return the SCA request context; may be null
+ */
+ RequestContext getRequestContext();
+
+
+ /* ******************** Contribution for issue TUSCANY-2281 ******************** */
+
+ /**
+ * Returns a Collection of typed service proxies for a business interface type and a reference name.
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param referenceName the name of the reference
+ * @param <B> the Java type of the business interface for the reference
+ * @return a Collection of objects that implements the business interface
+ */
+ <B> Collection<B> getServices(Class<B> businessInterface, String referenceName);
+
+
+ /**
+ * Returns a Collection of typed service reference for a business interface type and a reference name.
+ * @param businessInterface the interface that will be used to invoke the service
+ * @param referenceName the name of the reference
+ * @param <B> the Java type of the business interface for the reference
+ * @return a Collection of objects that implements the business interface
+ */
+ <B> Collection<ServiceReference<B>> getServiceReferences(Class<B> businessInterface, String referenceName);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java
new file mode 100644
index 0000000000..44045a404d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java
@@ -0,0 +1,23 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface Constants {
+ /**
+ * Namespace for intents.
+ */
+ String SCA_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+
+ /**
+ * Prefix form of the namespace that can be prepended to intent declarations.
+ */
+ String SCA_PREFIX = '{' + SCA_NS + '}';
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java
new file mode 100644
index 0000000000..0076ad34c0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. 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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java
new file mode 100644
index 0000000000..51a4dbe3ad
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.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.oasisopen.sca;
+
+public class NoSuchDomainException extends Exception {
+ private static final long serialVersionUID = -3990087696861167748L;
+
+ public NoSuchDomainException() {
+ super((Throwable)null);
+ }
+
+ public NoSuchDomainException(String message) {
+ super(message);
+ }
+
+ public NoSuchDomainException(Throwable cause) {
+ super(cause);
+ }
+
+ public NoSuchDomainException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java
new file mode 100644
index 0000000000..62d1b07f23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.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.oasisopen.sca;
+
+public class NoSuchServiceException extends Exception {
+ private static final long serialVersionUID = -3542376318558454581L;
+
+ public NoSuchServiceException() {
+ super((Throwable)null);
+ }
+
+ public NoSuchServiceException(String message) {
+ super(message);
+ }
+
+ public NoSuchServiceException(Throwable cause) {
+ super(cause);
+ }
+
+ public NoSuchServiceException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java
new file mode 100644
index 0000000000..e77934d44d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java
@@ -0,0 +1,55 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+import javax.security.auth.Subject;
+
+/**
+ * Interface that provides information on the current request.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface RequestContext {
+ /**
+ * Returns the JAAS Subject of the current request.
+ *
+ * @return the Subject of the current request
+ */
+ Subject getSecuritySubject();
+
+ /**
+ * Returns the name of the service that was invoked.
+ *
+ * @return the name of the service that was invoked
+ */
+ String getServiceName();
+
+ /**
+ * Returns a CallableReference for the service that was invoked by the caller.
+ *
+ * @param <B> the Java type of the business interface for the reference
+ * @return a CallableReference for the service that was invoked by the caller
+ */
+ <B> ServiceReference<B> getServiceReference();
+
+ /**
+ * Returns a type-safe reference to the callback provided by the caller.
+ *
+ * @param <CB> the Java type of the business interface for the callback
+ * @return a type-safe reference to the callback provided by the caller
+ */
+ <CB> CB getCallback();
+
+ /**
+ * Returns a CallableReference to the callback provided by the caller.
+ *
+ * @param <CB> the Java type of the business interface for the callback
+ * @return a CallableReference to the callback provided by the caller
+ */
+ <CB> ServiceReference<CB> getCallbackReference();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/SCARuntimeException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/SCARuntimeException.java
new file mode 100644
index 0000000000..ed957cff6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/SCARuntimeException.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.oasisopen.sca;
+
+public class SCARuntimeException extends RuntimeException {
+ private static final long serialVersionUID = -3867882539949395157L;
+
+ public SCARuntimeException() {
+ super((Throwable)null);
+ }
+
+ public SCARuntimeException(String message) {
+ super(message);
+ }
+
+ public SCARuntimeException(Throwable cause) {
+ super(cause);
+ }
+
+ public SCARuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java
new file mode 100644
index 0000000000..05c39cb04b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java
@@ -0,0 +1,22 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+import java.io.Serializable;
+
+
+/**
+ * A ServiceReference represents a client's perspective of a reference to another service.
+ *
+ * @version $Rev$ $Date$
+ * @param <B> the Java interface associated with this reference
+ */
+public interface ServiceReference<B> extends Serializable {
+ B getService();
+ Class<B> getBusinessInterface();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java
new file mode 100644
index 0000000000..d11c1904c5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java
@@ -0,0 +1,58 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+
+/**
+ * Base for Exceptions that may be raised by an SCA runtime and which typical
+ * application code is not expected to be able to handle.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = -3876058842262557092L;
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @see RuntimeException
+ */
+ public ServiceRuntimeException() {
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param message passed to RuntimeException
+ * @see RuntimeException
+ */
+ public ServiceRuntimeException(String message) {
+ super(message);
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param message passed to RuntimeException
+ * @param cause passed to RuntimeException
+ * @see RuntimeException
+ */
+ public ServiceRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Override constructor from RuntimeException.
+ *
+ * @param cause passed to RuntimeException
+ * @see RuntimeException
+ */
+ public ServiceRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java
new file mode 100644
index 0000000000..5d8e4af6ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java
@@ -0,0 +1,54 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+package org.oasisopen.sca;
+
+/**
+ * Exception used to indicate that a runtime exception occurred during the invocation of and external service.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ServiceUnavailableException extends ServiceRuntimeException {
+
+ private static final long serialVersionUID = -5869397223249401047L;
+
+ /**
+ * Constructs a new ServiceUnavailableException.
+ */
+ public ServiceUnavailableException() {
+ super((Throwable) null);
+ }
+
+ /**
+ * Constructs a new ServiceUnavailableException with the specified detail message.
+ *
+ * @param message The detail message (which is saved to later retrieval by the getMessage() method).
+ */
+ public ServiceUnavailableException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new ServiceUnavailableException with the specified cause.
+ *
+ * @param cause The cause (which is saved to later retrieval by the getCause() method).
+ */
+ public ServiceUnavailableException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Constructs a new ServiceUnavailableException with the specified detail message and cause.
+ *
+ * @param message The message (which is saved to later retrieval by the getMessage() method).
+ * @param cause The cause (which is saved to later retrieval by the getCause() method).
+ */
+ public ServiceUnavailableException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java
new file mode 100644
index 0000000000..e005da2414
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java
@@ -0,0 +1,35 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation on a service implementation class, on an individual method of a remotable service implementation,
+ * or on an individual reference which uses a remotable interface, where the reference is a field, a setter method,
+ * or a constructor parameter method.
+ * The annotation indicates that that the parameters and return value may safely
+ * be passed by reference. When the annotation is placed on a service implementation class or on a reference
+ * it indicates that all declared methods support this optimization.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({TYPE, METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface AllowsPassByReference {
+
+ boolean value() default true;
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java
new file mode 100644
index 0000000000..cfc0af0318
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java
@@ -0,0 +1,58 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation denoting the intent that service operations require authentication.
+ * <p/>
+ * Applied to the injection site (field, method or constructor parameter) for a reference,
+ * it indicates that all invocations through that reference require authentication.
+ * <p/>
+ * Applied to a interface method on a service contract, it indicates that all invocations
+ * of that service operation require authentication; applied to the type of a service contract,
+ * it indicates that all service operations on that interface require authentication.
+ * <p/>
+ * Applied to a method on an implementation class, it indicates that all invocations that
+ * are dispatched to that implementation method (through any service) require authentication.
+ * Applied to a interface implemented by an implementation class, it indicates that all
+ * invocations that are dispatched to the implementation method for that interface operation
+ * require authentication.
+ * <p/>
+ * Applied to an implementation class, it indicates that all invocations of that implementation
+ * and that all invocations made by that implementation require authentication.
+ *
+ * @version $Rev$ $Date$
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Authentication.AUTHENTICATION)
+public @interface Authentication {
+ String AUTHENTICATION = SCA_PREFIX + "authentication";
+ String AUTHENTICATION_MESSAGE = AUTHENTICATION + "message";
+ String AUTHENTICATION_TRANSPORT = AUTHENTICATION + "transport";
+
+ /**
+ * List of authentication qualifiers (such as "message" or "transport").
+ *
+ * @return authentication qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java
new file mode 100644
index 0000000000..76fcd866ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java
@@ -0,0 +1,30 @@
+/*
+ * 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.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 - for a method, for an implementation class, for a reference
+ * (either injected as a method parameter or injected into a field)
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Authorization.AUTHORIZATION)
+public @interface Authorization {
+ String AUTHORIZATION = SCA_PREFIX + "authorization";
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java
new file mode 100644
index 0000000000..b8d71dac05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java
@@ -0,0 +1,39 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * When placed on a service interface, this annotation specifies the interface
+ * to be used for callbacks.
+ * <p/>
+ * When placed on a method or field, this annotation denotes the injection
+ * site to be used for a callback reference.
+ * <p/>
+ * There is a error in the 1.00 draft spec in the declaration of this interface.
+ * The form defined here is a proposed correction for that error.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({TYPE, METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Callback {
+ /**
+ * The Class of the associated callback interface.
+ *
+ * @return the associated callback interface
+ */
+ Class<?> value() default Void.class;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java
new file mode 100644
index 0000000000..8fc3cd4013
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a field or method that is used to inject the component's name.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface ComponentName {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java
new file mode 100644
index 0000000000..5c594bc7d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java
@@ -0,0 +1,58 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation denoting the intent that service operations require confidentiality.
+ * <p/>
+ * Applied to the injection site (field, method or constructor parameter) for a reference,
+ * it indicates that all invocations through that reference require confidentiality.
+ * <p/>
+ * Applied to a interface method on a service contract, it indicates that all invocations
+ * of that service operation require confidentiality; applied to the type of a service contract,
+ * it indicates that all service operations on that interface require confidentiality.
+ * <p/>
+ * Applied to a method on an implementation class, it indicates that all invocations that
+ * are dispatched to that implementation method (through any service) require confidentiality.
+ * Applied to a interface implemented by an implementation class, it indicates that all
+ * invocations that are dispatched to the implementation method for that interface operation
+ * require confidentiality.
+ * <p/>
+ * Applied to an implementation class, it indicates that all invocations of that implementation
+ * and that all invocations made by that implementation require confidentiality.
+ *
+ * @version $Rev$ $Date$
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Confidentiality.CONFIDENTIALITY)
+public @interface Confidentiality {
+ String CONFIDENTIALITY = SCA_PREFIX + "confidentiality";
+ String CONFIDENTIALITY_MESSAGE = CONFIDENTIALITY + ".message";
+ String CONFIDENTIALITY_TRANSPORT = CONFIDENTIALITY + ".transport";
+
+ /**
+ * List of confidentiality qualifiers (such as "message" or "transport").
+ *
+ * @return confidentiality qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java
new file mode 100644
index 0000000000..a5728e51d4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java
new file mode 100644
index 0000000000..e7f7aef069
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java
@@ -0,0 +1,28 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a field or setter method that is used to inject an SCA context.
+ * The type of context injected is determined by the type of the field or the parameter
+ * to the setter method and is typically a ComponentContext or RequestContext.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD})
+@Retention(RUNTIME)
+public @interface Context {
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java
new file mode 100644
index 0000000000..2ad6fdc892
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a method that will be called by the container when the
+ * scope defined for the local service ends.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Destroy {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java
new file mode 100644
index 0000000000..d53e9e4fc4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate an instance should be eagerly initialized.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({TYPE})
+@Retention(RUNTIME)
+public @interface EagerInit {
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java
new file mode 100644
index 0000000000..3fe9bf585f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java
@@ -0,0 +1,26 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a method that will be called by the container when the scope defined for the local
+ * service begins.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Init {
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java
new file mode 100644
index 0000000000..0c196f1ce5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java
@@ -0,0 +1,58 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation denoting the intent that service operations require integrity.
+ * <p/>
+ * Applied to the injection site (field, method or constructor parameter) for a reference,
+ * it indicates that all invocations through that reference require integrity.
+ * <p/>
+ * Applied to a interface method on a service contract, it indicates that all invocations
+ * of that service operation require integrity; applied to the type of a service contract,
+ * it indicates that all service operations on that interface require integrity.
+ * <p/>
+ * Applied to a method on an implementation class, it indicates that all invocations that
+ * are dispatched to that implementation method (through any service) require integrity.
+ * Applied to a interface implemented by an implementation class, it indicates that all
+ * invocations that are dispatched to the implementation method for that interface operation
+ * require integrity.
+ * <p/>
+ * Applied to an implementation class, it indicates that all invocations of that implementation
+ * and that all invocations made by that implementation require integrity.
+ *
+ * @version $Rev$ $Date$
+ */
+@Inherited
+@Target({TYPE, FIELD, METHOD, PARAMETER})
+@Retention(RUNTIME)
+@Intent(Integrity.INTEGRITY)
+public @interface Integrity {
+ String INTEGRITY = SCA_PREFIX + "integrity";
+ String INTEGRITY_MESSAGE = INTEGRITY + "message";
+ String INTEGRITY_TRANSPORT = INTEGRITY + "transport";
+
+ /**
+ * List of integrity qualifiers (such as "message" or "transport").
+ *
+ * @return integrity qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java
new file mode 100644
index 0000000000..c3e9914f23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java
@@ -0,0 +1,48 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation that can be applied to annotations that describe SCA intents.
+ * Adding this annotation allows SCA runtimes to automatically detect user-defined intents.
+ * <p/>
+ * Applications must specify a value, a pairing of targetNamespace and localPort, or both.
+ * If both value and pairing are supplied they must define the name qualified name.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({ANNOTATION_TYPE})
+@Retention(RUNTIME)
+public @interface Intent {
+ /**
+ * The qualified name of the intent, in the form defined by {@link 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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java
new file mode 100644
index 0000000000..b12050a3e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java
@@ -0,0 +1,29 @@
+/*
+ * 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.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 {
+ String MANAGEDSHAREDTRANSACTION = SCA_PREFIX + "managedSharedTransaction";
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java
new file mode 100644
index 0000000000..7115e8a5e9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java
@@ -0,0 +1,40 @@
+/*
+ * 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.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 {
+ String MANAGEDTRANSACTION = SCA_PREFIX + "managedTransaction";
+ String MANAGEDTRANSACTION_MESSAGE = MANAGEDTRANSACTION + ".local";
+ String MANAGEDTRANSACTION_TRANSPORT = MANAGEDTRANSACTION + ".global";
+
+ /**
+ * List of managedTransaction qualifiers (such as "global" or "local").
+ *
+ * @return managedTransaction qualifiers
+ */
+ @Qualifier
+ String[] value() default "";
+}
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java
new file mode 100644
index 0000000000..d0825cd8e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java
@@ -0,0 +1,30 @@
+/*
+ * 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.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 {
+ String MUTUALAUTHENTICATION = SCA_PREFIX + "mutualAuthentication";
+}
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java
new file mode 100644
index 0000000000..b5ff494ca2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java
@@ -0,0 +1,29 @@
+/*
+ * 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.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 {
+ String NOMANAGEDTRANSACTION = SCA_PREFIX + "noManagedTransaction";
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java
new file mode 100644
index 0000000000..458d05cc92
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation on a method that indicates that the method is non-blocking and communication
+ * with the service provider may use buffer the requests and send them at some later time.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD})
+@Retention(RUNTIME)
+public @interface OneWay {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java
new file mode 100644
index 0000000000..150d8dabc8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java
@@ -0,0 +1,35 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation that allows application of SCA Policy Sets.
+ * <p/>
+ * Each policy set is specified using its XML QName in the form defined by {@link javax.xml.namespace.QName#toString()}.
+ *
+ * @version $Rev$ $Date$
+ */
+@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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java
new file mode 100644
index 0000000000..5905946627
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java
@@ -0,0 +1,38 @@
+/*
+ * 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.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;
+
+/**
+ * Annotation used to indicate a constructor parameter, field or method that is
+ * used to inject a configuration property value.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Property {
+ /**
+ * The name of the property. If not specified then the name will be derived
+ * from the annotated field or method.
+ *
+ * @return the name of the property
+ */
+ String name() default "";
+
+ /**
+ * Indicates whether a value for the property must be provided.
+ *
+ * @return true if a value must be provided
+ */
+ boolean required() default true;
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java
new file mode 100644
index 0000000000..a5fd102859
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java
@@ -0,0 +1,25 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation that can be applied to an attribute of an @Intent annotation to indicate the
+ * attribute provides qualifiers for the intent.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(METHOD)
+@Retention(RUNTIME)
+public @interface Qualifier {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java
new file mode 100644
index 0000000000..9a7154fcf3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java
@@ -0,0 +1,40 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a constructor parameter, field or method that is used to inject a reference.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target({METHOD, FIELD, PARAMETER})
+@Retention(RUNTIME)
+public @interface Reference {
+ /**
+ * The name of the reference. If not specified then the name will be derived from the annotated field or method.
+ *
+ * @return the name of the reference
+ */
+ String name() default "";
+
+ /**
+ * Indicates if a reference must be specified.
+ *
+ * @return true if a reference must be specified
+ */
+ boolean required() default true;
+}
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java
new file mode 100644
index 0000000000..77ff4e26f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java
@@ -0,0 +1,26 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a Java interface as remotable.
+ * Remotable interfaces use pass-by-value semantics, can be published as entry points
+ * and used for external services.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Remotable {
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java
new file mode 100644
index 0000000000..d90eb5512d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java
@@ -0,0 +1,46 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation that allows the attachment of any intent to a Java Class or interface or to members of that
+ * class such as methods, fields or constructor parameters.
+ * <p/>
+ * Intents are specified as XML QNames in the representation defined by
+ * {@link javax.xml.namespace.QName#toString()}. Intents may be qualified with one or more
+ * suffixes separated by a "." such as:
+ * <ul>
+ * <li>{http://docs.oasis-open.org/ns/opencsa/sca/200903}confidentiality</li>
+ * <li>{http://docs.oasis-open.org/ns/opencsa/sca/200903}confidentiality.message</li>
+ * </ul>
+ * This annotation supports general purpose intents specified as strings. Users may also define
+ * specific intents using the {@link @org.oasisopen.sca.annotation.Intent} annotation.
+ *
+ * @version $Rev$ $Date$
+ */
+@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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java
new file mode 100644
index 0000000000..b719355c73
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java
@@ -0,0 +1,36 @@
+/*
+ * (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., Sybase
+ * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved.
+ *
+ * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications
+ */
+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;
+
+/**
+ * Annotation used to indicate a scoped service.
+ * <p/>
+ * The spec refers to but does not describe an eager() attribute; this is an error in the draft.
+ *
+ * @version $Rev$ $Date$
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+public @interface Scope {
+ /**
+ * The name of the scope. Values currently defined by the specification are:
+ * <ul>
+ * <li>STATELESS (default)</li>
+ * <li>COMPOSITE</li>
+ * </ul>
+ *
+ * @return the name of the scope
+ */
+ String value() default "STATELESS";
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java
new file mode 100644
index 0000000000..a60754762e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java
@@ -0,0 +1,45 @@
+/*
+ * 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.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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java
new file mode 100644
index 0000000000..907330e93b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved. 2299
+ * OASIS trademark, IPR and other policies apply. 2300
+ */
+package org.oasisopen.sca.client;
+
+import java.net.URI;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+
+/**
+ * Client side helper that can be used to lookup SCA Services within a SCA Domain.
+ *
+ * @see SCAClientFactory
+ */
+public class SCAClient {
+
+ /**
+ * Returns a reference proxy that implements the business interface <T> of a
+ * service in a domain
+ *
+ * @param uri the URI of the target service. Takes the form domainURI/componentName/serviceName.
+ * The domainURI can be left off and defaults to the implementation specific default domain
+ * The service can also take the extended form
+ * domainURI/componentName/serviceName (or /componentName/serviceName).
+ * Can also take the extended form domainURI/componentName/serviceName/bindingName
+ * (or /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 static <T> T getService(Class<T> interfaze, String uri) throws NoSuchServiceException, NoSuchDomainException {
+ URI domainURI = null;
+ String serviceURI;
+ int i = uri.indexOf('/');
+ if (i == -1) {
+ domainURI = null;
+ serviceURI = uri;
+ } else {
+ serviceURI = uri.substring(i+1);
+ if (i > 0) {
+ domainURI = URI.create(uri.substring(0, i));
+ } else {
+ domainURI = null;
+ }
+ }
+ return SCAClientFactory.newInstance(domainURI).getService(interfaze, serviceURI);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java
new file mode 100644
index 0000000000..e96969c99d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. 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.impl.SCAClientFactoryFinder;
+
+/**
+ * The SCAClientFactory can be used by non-SCA managed code to lookup services
+ * that exist in a SCADomain.
+ *
+ * @see SCAClientFactoryFinder
+ * @see SCAClient
+ * @author OASIS Open
+ */
+public abstract class SCAClientFactory {
+
+ private URI domainURI;
+
+ private SCAClientFactory() {
+ }
+
+ /**
+ * Constructor used by concrete subclasses
+ * @param domainURI - The Domain URI of the Domain accessed via this SCAClientFactory
+ */
+ protected SCAClientFactory(URI domainURI) {
+ 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;
+ }
+
+ /**
+ * The default implementation of the SCAClientFactory. A Vendor may use
+ * reflection to inject a default SCAClientFactory instance that will be
+ * used in the newInstance() methods rather than using the
+ * SCAClientFactoryFinder.
+ */
+ protected static SCAClientFactory defaultFactory;
+
+ /**
+ * Creates a new instance of the SCAClient that can be used to lookup SCA
+ * Services.
+ *
+ * @return A new SCAClient
+ */
+ public static SCAClientFactory newInstance(URI domainURI) throws NoSuchDomainException {
+ return newInstance(null, null, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClient that can be used to lookup SCA
+ * Services.
+ *
+ * @param properties Properties that may be used when creating a new
+ * instance of the SCAClient
+ * @return A new SCAClient instance
+ */
+ public static SCAClientFactory newInstance(Properties properties, URI domainURI) {
+ return newInstance(properties, null, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClient that can be used to lookup SCA
+ * Services.
+ *
+ * @param classLoader ClassLoader that may be used when creating a new
+ * instance of the SCAClient
+ * @return A new SCAClient instance
+ */
+ public static SCAClientFactory newInstance(ClassLoader classLoader, URI domainURI) {
+ return newInstance(null, classLoader, domainURI);
+ }
+
+ /**
+ * Creates a new instance of the SCAClient that can be used to lookup SCA
+ * Services.
+ *
+ * @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 A new SCAClient instance
+ */
+ public static SCAClientFactory newInstance(Properties properties, ClassLoader classLoader, URI domainURI) {
+ final SCAClientFactory factory;
+ if (defaultFactory == null) {
+ factory = SCAClientFactoryFinder.find(properties, classLoader, domainURI);
+ } else {
+ factory = defaultFactory;
+ }
+ 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/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinder.java b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinder.java
new file mode 100644
index 0000000000..5137f8a658
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinder.java
@@ -0,0 +1,241 @@
+/*
+ * Copyright(C) OASIS(R) 2005,2009. All Rights Reserved.
+ * OASIS trademark, IPR and other policies apply.
+ */
+package org.oasisopen.sca.client.impl;
+
+import java.io.BufferedReader;
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URI;
+import java.net.URL;
+import java.util.Properties;
+
+import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+/**
+ * This is a default class that returns an SCAClientFactory implementation -
+ * this class can be replaced by a vendor implementation.
+ *
+ * @see SCAClientFactory
+ * @author OASIS Open
+ */
+public class 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 2488 the SPI
+ * implementation to use for the SCAClientFactory. 2489
+ */
+ private static final String SCA_CLIENT_FACTORY_PROVIDER_META_INF_SERVICE = "META-INF/services/" + SCA_CLIENT_FACTORY_PROVIDER_KEY;
+
+ /**
+ * Private Constructor.
+ */
+ private SCAClientFactoryFinder() {
+ }
+
+ /**
+ * Creates an instance of the SCAClientFactory implementation. This
+ * discovers the SCAClientFactory 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 SCARuntimeException Failed to create SCAClientFactory
+ * implementation.
+ */
+ public static SCAClientFactory find(Properties properties, ClassLoader classLoader, URI domainURI) {
+ if (classLoader == null) {
+ classLoader = getThreadContextClassLoader();
+ if (classLoader == null) {
+ classLoader = SCAClientFactoryFinder.class.getClassLoader();
+ }
+ }
+ 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 SCAClientFactory
+ * implementation from the specified Properties, the System Properties or
+ * the specified ClassLoader.
+ *
+ * @return The class name of the SCAClientFactory implementation
+ * @throw SCARuntimeException Failed to find implementation for
+ * SCAClientFactory.
+ */
+ private static String discoverProviderFactoryImplClass(Properties properties, ClassLoader classLoader) throws SCARuntimeException {
+ String providerClassName = checkPropertiesForSPIClassName(properties);
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ providerClassName = checkPropertiesForSPIClassName(System.getProperties());
+ if (providerClassName != null) {
+ return providerClassName;
+ }
+
+ return checkMETAINFServicesForClassName(classLoader);
+ }
+
+ /**
+ * Attempts to find the class name for the SCAClientFactory implementation
+ * from the specified Properties.
+ *
+ * @return The class name for the SCAClientFactory 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 SCAClientFactory implementation
+ * from the META-INF/services directory
+ *
+ * @return The class name for the SCAClientFactory implementation or
+ * <code>null</code> if not found.
+ */
+ private static String checkMETAINFServicesForClassName(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 SCARuntimeException("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 SCARuntimeException Failed to load the SCAClientFactory
+ * implementation class
+ */
+ private static Class<? extends SCAClientFactory> loadProviderFactoryClass(String factoryImplClassName, ClassLoader classLoader)
+ throws SCARuntimeException {
+
+ try {
+ final Class<?> providerClass = classLoader.loadClass(factoryImplClassName);
+ final Class<? extends SCAClientFactory> providerFactoryClass = providerClass.asSubclass(SCAClientFactory.class);
+ return providerFactoryClass;
+ } catch (ClassNotFoundException ex) {
+ throw new SCARuntimeException("Failed to load SCAClientFactory implementation class " + factoryImplClassName, ex);
+ } catch (ClassCastException ex) {
+ throw new SCARuntimeException("Loaded SCAClientFactory implementation class " + factoryImplClassName
+ + " is not a subclass of "
+ + SCAClientFactory.class.getName(), ex);
+ }
+ }
+
+ /**
+ * Instantiate an instance of the specified SCAClientFactory implementation
+ * class.
+ *
+ * @param factoryImplClass The SCAClientFactory implementation class to
+ * instantiate.
+ * @param domainURI
+ * @return An instance of the SCAClientFactory implementation class
+ * @throws SCARuntimeException Failed to instantiate the specified specified
+ * SCAClientFactory implementation class
+ */
+ private static SCAClientFactory instantiateSCAClientFactoryClass(Class<? extends SCAClientFactory> factoryImplClass, URI domainURI) throws SCARuntimeException {
+
+ try {
+ final SCAClientFactory provider = factoryImplClass.getConstructor(URI.class).newInstance(domainURI);
+ return provider;
+ } catch (Throwable ex) {
+ ex.printStackTrace();
+ throw new SCARuntimeException("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 SCARuntimeException("Failed to close stream", ex);
+ }
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..c121ce7830
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Client Impl
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397189093
+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.node;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/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/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/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/pom.xml
new file mode 100644
index 0000000000..bf019910f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
new file mode 100644
index 0000000000..ba8d6793e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.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.client.impl;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFinder;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.ServiceUnavailableException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+public class SCAClientFactoryImpl extends SCAClientFactory {
+
+ public SCAClientFactoryImpl(URI domainURI) {
+ super(domainURI);
+ }
+
+ @Override
+ public <T> T getService(Class<T> serviceInterface, String serviceName) throws NoSuchServiceException, NoSuchDomainException {
+ URI domainURI = getDomainURI();
+ if (domainURI == null) {
+ domainURI = URI.create(Node.DEFAULT_DOMAIN_URI);
+ }
+ List<Node> nodes = NodeFinder.getNodes(domainURI);
+ if (nodes == null || nodes.size() < 1) {
+ throw new NoSuchDomainException(domainURI.toString());
+ }
+
+ for (Node n : nodes) {
+ try {
+ return n.getService(serviceInterface, serviceName);
+ } catch(ServiceUnavailableException e) {
+ // Ingore and continue
+ }
+ }
+
+ throw new NoSuchServiceException(serviceName);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
new file mode 100644
index 0000000000..3a90a22a85
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory
@@ -0,0 +1,2 @@
+org.apache.tuscany.sca.client.impl.SCAClientFactoryImpl
+
diff --git a/tags/java/sca/2.0-M4-RC2/modules/stripes/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/stripes/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/stripes/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/stripes/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0fe5e58281
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/stripes/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Webapp Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bnd-LastModified: 1222833658000
+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",
+ net.sourceforge.stripes.action;version="1.5",
+ net.sourceforge.stripes.config;version="1.5",
+ net.sourceforge.stripes.controller;version="1.5",
+ net.sourceforge.stripes.exception;version="1.5",
+ net.sourceforge.stripes.util;version="1.5",
+ org.apache.tuscany.sca.core;version="2.0",
+ org.apache.tuscany.sca.host.http;version="2.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0",
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca;version="2.0",
+ org.oasisopen.sca.annotation;version="2.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/tags/java/sca/2.0-M4-RC2/modules/stripes/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/stripes/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/stripes/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/stripes/pom.xml
new file mode 100644
index 0000000000..e3bbca43af
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>1.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java b/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java
new file mode 100644
index 0000000000..f4d7f48dae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java b/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java
new file mode 100644
index 0000000000..1381266c9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java b/tags/java/sca/2.0-M4-RC2/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java
new file mode 100644
index 0000000000..4c73f28a08
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/wicket/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/wicket/LICENSE
new file mode 100644
index 0000000000..c77d3fe856
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/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/tags/java/sca/2.0-M4-RC2/modules/wicket/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/wicket/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..0fe5e58281
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/META-INF/MANIFEST.MF
@@ -0,0 +1,31 @@
+Manifest-Version: 1.0
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA Webapp Host
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0
+Bnd-LastModified: 1222833658000
+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",
+ net.sourceforge.stripes.action;version="1.5",
+ net.sourceforge.stripes.config;version="1.5",
+ net.sourceforge.stripes.controller;version="1.5",
+ net.sourceforge.stripes.exception;version="1.5",
+ net.sourceforge.stripes.util;version="1.5",
+ org.apache.tuscany.sca.core;version="2.0",
+ org.apache.tuscany.sca.host.http;version="2.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0",
+ org.apache.tuscany.sca.implementation.web.runtime.utils;version="2.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
+ org.oasisopen.sca;version="2.0",
+ org.oasisopen.sca.annotation;version="2.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/tags/java/sca/2.0-M4-RC2/modules/wicket/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/wicket/NOTICE
new file mode 100644
index 0000000000..dfde08644b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/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/tags/java/sca/2.0-M4-RC2/modules/wicket/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/wicket/pom.xml
new file mode 100644
index 0000000000..8fc366e3e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/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-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>tuscany-wicket</artifactId>
+ <name>Apache Tuscany SCA Wicket Web Framework Integration</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>1.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket-ioc</artifactId>
+ <version>1.4.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/IContextLocator.java b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/IContextLocator.java
new file mode 100644
index 0000000000..589c240b84
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/IContextLocator.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.wicket;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.IClusterable;
+
+
+/**
+ * Interface representing object that can locate a spring context. The implementation should take up
+ * little room when serialized.
+ *
+ * SpringObjectLocator uses this interface to locate the spring context so that it in turn can
+ * locate a bean.
+ *
+ * Ideal implementations use a static lookup to locate the context.
+ *
+ * For Example:
+ *
+ * <pre>
+ * class SpringContextLocator implements ISpringContextLocator
+ * {
+ * public ApplicationContext getSpringContext()
+ * {
+ * //MyApplication is the subclass of WebApplication used by the application
+ * return ((MyApplication)Application.get()).getContext();
+ * }
+ * }
+ * </pre>
+ *
+ * @see SpringBeanLocator
+ *
+ * Based on code from Apache Wicket by Igor Vaynberg
+ */
+public interface IContextLocator extends IClusterable
+{
+ /**
+ * Getter for spring application context
+ *
+ * @return spring application context
+ */
+ ServletContext getServletContext();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyComponentInjector.java b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyComponentInjector.java
new file mode 100644
index 0000000000..b1e9097cdf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyComponentInjector.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.wicket;
+import javax.servlet.ServletContext;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.IClusterable;
+import org.apache.wicket.MetaDataKey;
+import org.apache.wicket.Session;
+import org.apache.wicket.application.IComponentInstantiationListener;
+import org.apache.wicket.injection.ComponentInjector;
+import org.apache.wicket.injection.web.InjectorHolder;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.protocol.http.WebApplication;
+
+/**
+ * {@link IComponentInstantiationListener} that injects component properties annotated with {@link
+ * SpringBean} annotations.
+ *
+ * To install in yourapplication.init() call
+ * <code>addComponentInstantiationListener(new SpringComponentInjector(this));</code> Non-wicket
+ * components such as {@link Session}, {@link Model}, and any other pojo can be injected by calling
+ * <code>InjectorHolder.getInjector().inject(this)</code> in their constructor.
+ *
+ * Based on code from Apache Wicket by Igor Vaynberg and Justin Lee
+ */
+public class TuscanyComponentInjector extends ComponentInjector
+{
+
+ /**
+ * Metadata key used to store application context holder in application's metadata
+ */
+ private static MetaDataKey<ApplicationContextHolder> CONTEXT_KEY = new MetaDataKey<ApplicationContextHolder>()
+ {
+
+ private static final long serialVersionUID = 1L;
+
+ };
+
+ /**
+ * Constructor used when spring application context is declared in the spring standard way and
+ * can be located through {@link
+ * WebApplicationContextUtils#getRequiredWebApplicationContext(ServletContext)}
+ *
+ * @param webapp
+ * wicket web application
+ */
+ public TuscanyComponentInjector(WebApplication webapp)
+ {
+ // locate application context through spring's default location
+ // mechanism and pass it on to the proper constructor
+ this(webapp, webapp.getServletContext());
+ }
+
+ /**
+ * Constructor
+ *
+ * @param webapp
+ * wicket web application
+ * @param ctx
+ * spring's application context
+ */
+ public TuscanyComponentInjector(WebApplication webapp, ServletContext ctx)
+ {
+ if (webapp == null)
+ {
+ throw new IllegalArgumentException("Argument [[webapp]] cannot be null");
+ }
+
+ if (ctx == null)
+ {
+ throw new IllegalArgumentException("Argument [[ctx]] cannot be null");
+ }
+
+ // store context in application's metadata ...
+ webapp.setMetaData(CONTEXT_KEY, new ApplicationContextHolder(ctx));
+
+ // ... and create and register the annotation aware injector
+ InjectorHolder.setInjector(new TuscanyInjector(new ContextLocator()));
+ }
+
+ /**
+ * This is a holder for the application context. The reason we need a holder is that metadata
+ * only supports storing serializable objects but application context is not. The holder acts as
+ * a serializable wrapper for the context. Notice that although holder implements IClusterable
+ * it really is not because it has a reference to non serializable context - but this is ok
+ * because metadata objects in application are never serialized.
+ *
+ * @author ivaynberg
+ *
+ */
+ private static class ApplicationContextHolder implements IClusterable
+ {
+ private static final long serialVersionUID = 1L;
+
+ private final ServletContext context;
+
+ /**
+ * Constructor
+ *
+ * @param context
+ */
+ public ApplicationContextHolder(ServletContext context)
+ {
+ this.context = context;
+ }
+
+ /**
+ * @return the context
+ */
+ public ServletContext getContext()
+ {
+ return context;
+ }
+ }
+
+ /**
+ * A context locator that locates the context in application's metadata. This locator also keeps
+ * a transient cache of the lookup.
+ *
+ * @author ivaynberg
+ *
+ */
+ private static class ContextLocator implements IContextLocator
+ {
+ private transient ServletContext context;
+
+ private static final long serialVersionUID = 1L;
+
+ public ServletContext getServletContext()
+ {
+ if (context == null)
+ {
+ context = (Application.get().getMetaData(CONTEXT_KEY)).getContext();
+ }
+ return context;
+ }
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyFieldValueFactory.java b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyFieldValueFactory.java
new file mode 100644
index 0000000000..f2814fbcbe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyFieldValueFactory.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.wicket;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.sca.implementation.web.runtime.utils.ContextHelper;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.wicket.injection.IFieldValueFactory;
+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 TuscanyFieldValueFactory implements IFieldValueFactory {
+
+ private IContextLocator contextLocator;
+
+ public TuscanyFieldValueFactory(IContextLocator contextLocator) {
+ this.contextLocator = contextLocator;
+ }
+
+ public Object getFieldValue(Field field, Object instance) {
+ Object value = null;
+ if (field.isAnnotationPresent(Reference.class)) {
+ Reference ref = field.getAnnotation(Reference.class);
+ String name = ref.name() != null && !ref.name().equals("") ? ref.name() : field.getName();
+ value = ContextHelper.getReference(name, field.getType(), contextLocator.getServletContext());
+ } else if (field.isAnnotationPresent(Property.class)) {
+ Property prop = field.getAnnotation(Property.class);
+ String name = prop.name() != null && !prop.name().equals("") ? prop.name() : field.getName();
+ value = ContextHelper.getProperty(name, contextLocator.getServletContext());
+ } else if (field.isAnnotationPresent(ComponentName.class)) {
+ RuntimeComponent rc = (RuntimeComponent)contextLocator.getServletContext().getAttribute(ContextHelper.COMPONENT_ATTR);
+ value = rc.getName();
+ } else if (field.isAnnotationPresent(Context.class)) {
+ value = ContextHelper.getComponentContext(contextLocator.getServletContext());
+ }
+ return value;
+ }
+
+ public boolean supportsField(Field field) {
+ return field.isAnnotationPresent(Reference.class)
+ || field.isAnnotationPresent(Property.class)
+ || field.isAnnotationPresent(Context.class)
+ || field.isAnnotationPresent(ComponentName.class);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyInjector.java b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyInjector.java
new file mode 100644
index 0000000000..03c44d96f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyInjector.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.wicket;
+
+import org.apache.wicket.injection.ConfigurableInjector;
+import org.apache.wicket.injection.IFieldValueFactory;
+
+public class TuscanyInjector extends ConfigurableInjector {
+
+ private TuscanyFieldValueFactory factory;
+
+ public TuscanyInjector(IContextLocator contextLocator) {
+ factory = new TuscanyFieldValueFactory(contextLocator);
+ }
+
+ @Override
+ protected IFieldValueFactory getFieldValueFactory() {
+ return factory;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/xsd/LICENSE b/tags/java/sca/2.0-M4-RC2/modules/xsd/LICENSE
new file mode 100644
index 0000000000..8aa906c321
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/modules/xsd/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..b8bb9642f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/xsd/META-INF/MANIFEST.MF
@@ -0,0 +1,47 @@
+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"
+Tool: Bnd-0.0.255
+Bundle-Name: Apache Tuscany SCA XSD Model
+Created-By: 1.6.0_07 (Sun Microsystems Inc.)
+Bundle-Vendor: The Apache Software Foundation
+Bundle-Version: 2.0.0
+Bnd-LastModified: 1225397174343
+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.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/tags/java/sca/2.0-M4-RC2/modules/xsd/NOTICE b/tags/java/sca/2.0-M4-RC2/modules/xsd/NOTICE
new file mode 100644
index 0000000000..25bb89c9b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/xsd/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/tags/java/sca/2.0-M4-RC2/modules/xsd/pom.xml b/tags/java/sca/2.0-M4-RC2/modules/xsd/pom.xml
new file mode 100644
index 0000000000..3ccc10e72d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-M4</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-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ws.commons.schema</groupId>
+ <artifactId>XmlSchema</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-contribution</artifactId>
+ <version>2.0-M4</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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java
new file mode 100644
index 0000000000..92dce98fa1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java
new file mode 100644
index 0000000000..08a1c8dd63
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.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;
+
+/**
+ * Factory for XSD definitions
+ *
+ * @version $Rev$ $Date$
+ */
+public interface XSDFactory {
+
+ /**
+ * Creates a new XML Schema definition.
+ *
+ * @return a new XML Schema definition
+ */
+ XSDefinition createXSDefinition();
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java
new file mode 100644
index 0000000000..f9bf627655
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.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.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$
+ */
+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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java
new file mode 100644
index 0000000000..60ff6b6fd9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java
new file mode 100644
index 0000000000..af8cbf12ab
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java
new file mode 100644
index 0000000000..1166567bcc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
new file mode 100644
index 0000000000..63ecf5d56f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java
@@ -0,0 +1,328 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.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);
+ 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 = schemaCollection.read(definition.getDocument(), uri, null);
+ 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 (d.getTargetNamespace().equals(definition.getNamespace())) {
+ if (d.getSourceURI().equals(definition.getLocation().toString())) {
+ schema = d;
+ break;
+ }
+ }
+ }
+ if (schema == null) {
+ InputSource xsd = XMLDocumentHelper.getInputSource(definition.getLocation().toURL());
+ schema = schemaCollection.read(xsd, null);
+ }
+ definition.setSchemaCollection(schemaCollection);
+ definition.setSchema(schema);
+ }
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * 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);
+
+ // Collection of namespace imports with location
+ List<String> locations = new ArrayList<String>();
+ 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(targetNamespace)) {
+ if (namespaceImport.getLocation() == null) {
+ // 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 {
+ // We might have multiple imports for the same namespace,
+ // need to search them in lexical order.
+ locations.add(namespaceImport.getLocation());
+ locationMap.put(namespaceImport.getLocation(), namespaceImport);
+ }
+ }
+ } 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());
+ }
+ }
+ }
+ // Search namespace imports with location 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(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;
+ }
+ }
+ } else {
+ 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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory
new file mode 100644
index 0000000000..d51b2445a4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties
new file mode 100644
index 0000000000..ab50456510
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java
new file mode 100644
index 0000000000..e139625986
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/greeting.xsd b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/greeting.xsd
new file mode 100644
index 0000000000..635ca25bfc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/name.xsd b/tags/java/sca/2.0-M4-RC2/modules/xsd/src/test/resources/xsd/name.xsd
new file mode 100644
index 0000000000..300de931ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/pom.xml b/tags/java/sca/2.0-M4-RC2/pom.xml
new file mode 100644
index 0000000000..bff90abffa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/pom.xml
@@ -0,0 +1,832 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. 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>4</version>
+ </parent>
+
+ <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-M4</version>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/tuscany/java/sca</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/tuscany/java/sca</developerConnection>
+ <url>http://svn.apache.org/repos/asf/tuscany/java/sca</url>
+ </scm>
+
+ <prerequisites>
+ <maven>2.0.6</maven>
+ </prerequisites>
+
+ <properties>
+ <notice.dir>.</notice.dir>
+ </properties>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/jira/browse/TUSCANY</url>
+ </issueManagement>
+
+ <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://people.apache.org/repo/m2-snapshot-repository</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>
+
+ <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://people.apache.org/repo/m2-snapshot-repository</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>
+
+ <distributionManagement>
+ <repository>
+ <id>apache.releases</id>
+ <name>Apache Release Distribution Repository</name>
+ <url>scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository</url>
+ </repository>
+ <snapshotRepository>
+ <id>apache.snapshots</id>
+ <name>Apache Development Snapshot Repository</name>
+ <url>scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
+ <uniqueVersion>false</uniqueVersion>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+<!--
+ <module>stest</module>
+ <module>vtest</module>
+-->
+ </modules>
+ </profile>
+
+ <profile>
+ <id>distribution</id>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>features</module>
+ <module>distribution</module>
+ <module>archetypes</module>
+<!--
+ <module>vtest</module>
+-->
+ </modules>
+ </profile>
+
+ <profile>
+ <id>sources</id>
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>vtest</module>
+ <module>tutorials</module>
+ </modules>
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <configuration>
+ <attach>true</attach>
+ </configuration>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>eclipse</id>
+<!--
+ <properties>
+ <notice.dir>src/main/resources</notice.dir>
+ </properties>
+-->
+ <modules>
+ <module>modules</module>
+ <module>samples</module>
+ <module>itest</module>
+ <module>otest/current</module>
+ <!--module>vtest</module-->
+ <!--module>tutorials</module-->
+ <!--module>demos</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>
+ <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>2.0-M4</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-M4</version>
+ <executions>
+ <execution>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>security</id>
+ <modules>
+ <!-- <module>demos</module> -->
+ <module>itest</module>
+ <module>vtest</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.5</source>
+ <target>1.5</target>
+ <showDeprecation>true</showDeprecation>
+ <compilerArgument>-Xlint:unchecked,deprecation,fallthrough,finally</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <profile>
+ <id>release</id>
+ <modules>
+ <module>modules</module>
+ <module>archetypes</module>
+ </modules>
+ <build>
+ <plugins>
+
+ <plugin>
+ <inherited>true</inherited>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.4</version>
+ <configuration>
+ <altDeploymentRepository>${deploy.altRepository}</altDeploymentRepository>
+ <updateReleaseInfo>true</updateReleaseInfo>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.0-alpha-4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </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-sca-runtime</module>
+ <module>modules/binding-ws</module>
+ <module>modules/binding-ws-axis2-policy</module>
+ <module>modules/binding-ws-wsdlgen</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-axiom</module>
+ <module>modules/databinding-jaxb</module>
+ <module>modules/domain-node</module>
+ <module>modules/endpoint-tribes</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/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/xsd</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>
+
+ <profile>
+ <id>scajcaa</id>
+ <modules>
+<!-- base -->
+ <module>modules/assembly</module>
+ <module>modules/assembly-xml</module>
+ <module>modules/assembly-xsd</module>
+ <module>modules/binding-sca-runtime</module>
+ <module>modules/binding-ws</module>
+ <module>modules/binding-ws-axis2-policy</module>
+ <module>modules/binding-ws-wsdlgen</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-axiom</module>
+ <module>modules/databinding-jaxb</module>
+ <module>modules/domain-node</module>
+ <module>modules/endpoint-tribes</module>
+ <module>modules/extensibility</module>
+ <module>modules/host-http</module>
+ <module>modules/host-jetty</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/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/xsd</module>
+<!-- WS -->
+ <module>modules/databinding-jaxb-axiom</module>
+ <module>modules/policy-xml-ws</module>
+ <module>modules/binding-ws-axis2</module>
+<!-- OSGi -->
+ <module>modules/extensibility-equinox</module>
+ <module>modules/node-launcher-equinox</module>
+<!-- SCA-J CAA -->
+<!--
+ <module>otest\newlayout\sca-java-caa</module>
+-->
+ <module>otest\newlayout\sca-java-caa\JCA_0000</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10001</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10002</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10003</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10004</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10006</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10007</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10008</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10009</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10010</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10011</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10014</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10015</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10046</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10047</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10048</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10049</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10050</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10051</module>
+ <module>otest\newlayout\sca-java-caa\JCA_10052</module>
+ <module>otest\newlayout\sca-java-caa\JCA_11005</module>
+ <module>otest\newlayout\sca-java-caa\JCA_2001</module>
+ <module>otest\newlayout\sca-java-caa\JCA_2002</module>
+ <module>otest\newlayout\sca-java-caa\JCA_2003</module>
+ <module>otest\newlayout\sca-java-caa\JCA_2004</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3001</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3002</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3003</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3004</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3005</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3006</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3007</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3008</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3009</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3010</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3011</module>
+ <module>otest\newlayout\sca-java-caa\JCA_3012</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8001</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8002</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8003</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8004</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8006</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8008</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8009</module>
+ <module>otest\newlayout\sca-java-caa\JCA_8010</module>
+ <module>otest\newlayout\sca-java-caa\JCA_General_POJO</module>
+<!-- Tuscany SCA-J CAA -->
+ <module>otest\newlayout\tuscany-java-caa-test-runner</module>
+ </modules>
+ </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>
+
+ <pluginManagement>
+ <plugins>
+
+ <!-- compiler plugin configuration -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <compilerId>tuscany-eclipse</compilerId>
+ <source>1.5</source>
+ <target>1.5</target>
+ <compilerArguments>
+ <osgi>true</osgi>
+ </compilerArguments>
+ </configuration>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.maven.plugins</groupId>
+ <artifactId>maven-eclipse-compiler</artifactId>
+ <version>1.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ </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 -Xmx256m</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.5</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>
+ </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/tags/java/sca</tagBase>
+ <useReleaseProfile>false</useReleaseProfile>
+ <preparationGoals>clean install</preparationGoals>
+ <goals>deploy</goals>
+ <arguments>-Prelease,deploy</arguments>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/README b/tags/java/sca/2.0-M4-RC2/samples/README
new file mode 100644
index 0000000000..4ccefa3695
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/README
@@ -0,0 +1,232 @@
+The Apache Tuscany SCA 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 Overview
+---------------
+The samples generally show off different features of the SCA runtime
+and the extensions that come packaged with it.
+
+binding-ws-calculator - Calculator running inside a web app also
+ showing webservices binding
+
+calculator - Calculator built with java components and
+ local wires.
+
+calculator-equinox - Calculator running inside a Equinox OSGi runtime
+
+calculator-osgi - Calculator running inside a OSGi runtime
+
+calculator-rmi-reference - The calculator configured to talk RMI to
+ the calculator-rmi-service sample
+calculator-rmi-service - The calculator configured to accept RMI
+ requests from calculator-rmi-reference
+
+implementation-java-calculator
+
+
+Sample Layout
+-------------
+All 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.
+ calculator
+ Import all of the sample code and resources into this project, e.g.
+ File, Import and then select tuscany-sca-1.0-incubating\samples\calculator from the filesystem
+ Configure the source path to include
+ src/main/java
+ src/main/resources
+ Configure the output folder to be
+ calculator/target
+ Configure the build path to include the manifest jar tuscany-sca-manifiest.jar provided in
+ features
+ If you select calculator.CalculatorClient.java and run as "Java Application" you should see
+ 3 + 2=5.0
+ 3 - 2=1.0
+ 3 * 2=6.0
+ 3 / 2=1.5
+
+The details of how to do this for other development environments will
+vary but the process will be similar.
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/README b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/README
new file mode 100644
index 0000000000..fb5afcc7ec
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/README
@@ -0,0 +1,97 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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 -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-binding-ws-calculator.jar sample.SampleClientImpl
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-binding-ws-calculator.jar sample.SampleClientImpl
+
+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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/build.xml b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/build.xml
new file mode 100644
index 0000000000..e13ec494b0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/build.xml
@@ -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.
+-->
+<project name="binding-ws-calculator" default="run">
+
+ <property name="jar.name" value="sample-binding-ws-calculator.jar" />
+ <property name="main.class" value="sample.SampleClientImpl" />
+
+ <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="../../modules">
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-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>
+
+ <target name="run" depends="compile">
+ <java classname="org.apache.tuscany.sca.launcher.LauncherMain"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="../../bin/launcher.jar"/>
+ </classpath>
+ <arg value="unmanaged"/>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.png b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.png
new file mode 100644
index 0000000000..995a57b1fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.svg b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.svg
new file mode 100644
index 0000000000..af34f07e04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/calculator.svg
@@ -0,0 +1,329 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator"
+ sodipodi:docname="calculator.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator\calculator.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="471.80491"
+ inkscape:cy="378.84265"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1054"
+ inkscape:window-height="721"
+ inkscape:window-x="59"
+ inkscape:window-y="79" />
+ <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(1,0,0,1.144214,0,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.86971939;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">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
+ id="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%" /></flowRegion><flowPara
+ id="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="594.75488"
+ y="209.73451"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(334.4498,10.22481)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Add</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">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 573.31867,232.29606 L 606.65371,232.29606 L 612.71462,245.42804 L 605.64356,257.54988 L 573.31867,257.54988 L 580.89482,245.42804 L 573.31867,232.29606 z "
+ id="path1913" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1917"
+ width="115.66247"
+ height="70.148659"
+ x="594.06543"
+ y="292.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1919"
+ transform="translate(333.7604,93.08188)"><flowRegion
+ id="flowRegion1921"><rect
+ id="rect1923"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1925">Subtract</flowPara><flowPara
+ id="flowPara1927">Service</flowPara><flowPara
+ id="flowPara1929">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 572.62924,315.15313 L 605.96428,315.15313 L 612.02519,328.28511 L 604.95413,340.40695 L 572.62924,340.40695 L 580.20539,328.28511 L 572.62924,315.15313 z "
+ id="path1931" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1933"
+ width="115.66247"
+ height="70.148659"
+ x="594.77979"
+ y="371.87729"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1935"
+ transform="translate(334.4747,172.3676)"><flowRegion
+ id="flowRegion1937"><rect
+ id="rect1939"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1941">Multiply</flowPara><flowPara
+ id="flowPara1943">Service</flowPara><flowPara
+ id="flowPara1945">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 573.34352,394.43884 L 606.67856,394.43884 L 612.73947,407.57082 L 605.66841,419.69266 L 573.34352,419.69266 L 580.91967,407.57082 L 573.34352,394.43884 z "
+ id="path1947" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1949"
+ width="115.66247"
+ height="70.148659"
+ x="596.20831"
+ y="452.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1951"
+ transform="translate(335.9032,253.0819)"><flowRegion
+ id="flowRegion1953"><rect
+ id="rect1955"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1957">Divide</flowPara><flowPara
+ id="flowPara1959">Service</flowPara><flowPara
+ id="flowPara1961">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 574.77209,475.15313 L 608.10713,475.15313 L 614.16804,488.28511 L 607.09698,500.40695 L 574.77209,500.40695 L 582.34824,488.28511 L 574.77209,475.15313 z "
+ id="path1963" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/pom.xml
new file mode 100644
index 0000000000..67cdee5815
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-binding-ws-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Binding WS Calculator</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-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </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>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..dd7ecb827d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..7ca8fb04b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java
new file mode 100644
index 0000000000..7e5ff160f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.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;
+
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+import sample.SampleClient;
+
+/**
+ * This client program shows how to create an SCA runtime, start it,
+ * and locate and invoke a SCA component
+ */
+@Scope("COMPOSITE")
+public class CalculatorClientImpl implements SampleClient {
+
+ private CalculatorService calculatorService;
+
+ @Reference
+ public void setCalculatorService(CalculatorService calculatorService) {
+ this.calculatorService = calculatorService;
+ }
+
+ /**
+ * This code used to be in an @Init method which removed the need for a JSE client
+ * to prod the compoite. However OASIS is debating whether to allow references to be used
+ * inside @Init methods and it can cause deadlocks in our runtime. So rather than make
+ * changes in the runtime we are falling backon the JSE drive mechanism until we know
+ * which way the specs are going
+ */
+ public void runSample() {
+ 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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..031fa8b912
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..17fad7de6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java
new file mode 100644
index 0000000000..6620f6a5e7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.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 sample;
+
+/**
+ * The sample service interface.
+ */
+public interface SampleClient {
+ void runSample();
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java
new file mode 100644
index 0000000000..000c108934
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.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 sample;
+
+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 SampleClientImpl {
+ public static void main(String[] args) throws Exception {
+ String location = ContributionLocationHelper.getContributionLocation(SampleClient.class);
+ Node node = NodeFactory.newInstance().createNode(new Contribution("c1", location));
+
+ node.start();
+
+ SampleClient sampleClient = node.getService(SampleClient.class, "SampleClient");
+ sampleClient.runSample();
+
+ node.stop();
+
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..29dd7e3b6f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/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/200903"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="Calculator">
+
+ <component name="SampleClient">
+ <implementation.java class="calculator.CalculatorClientImpl"/>
+ <reference name="calculatorService" target="CalculatorServiceComponent" />
+ </component>
+
+ <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/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..27a1ee74e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..8f6b5e4845
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.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.junit.Test;
+
+import sample.SampleClientImpl;
+
+/**
+ * Test the Calculator composition.
+ */
+public class CalculatorTestCase {
+
+ @Test
+ public void testSample() throws Exception {
+ SampleClientImpl.main(null);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/build-common.xml b/tags/java/sca/2.0-M4-RC2/samples/build-common.xml
new file mode 100644
index 0000000000..64d23d3793
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/build-common.xml
@@ -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.
+-->
+
+<project name="common">
+ <!-- Set the distro path based on the existence of the pom.xml -->
+ <condition property="distro.path" value="../../distribution/all/target" else="../..">
+ <available file="../../distribution/pom.xml"/>
+ </condition>
+
+ <!-- Convert the path to an absolute location -->
+ <property name="distro.root" location="${distro.path}"/>
+ <echo>Distribution: ${distro.root}</echo>
+
+ <!-- @file is relative to the enclosing file -->
+ <import file="${distro.root}/features/build-path.xml"/>
+
+ <target name="common-init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="${sample.root}/target/classes"/>
+ </target>
+
+ <target name="common-jar-compile" depends="common-init">
+ <javac srcdir="${sample.root}/src/main/java"
+ destdir="${sample.root}/target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath refid="tuscany.path"/>
+ </javac>
+ <copy todir="${sample.root}/target/classes">
+ <fileset dir="${sample.root}/src/main/resources"/>
+ </copy>
+ <jar destfile="${sample.jar}" basedir="${sample.root}/target/classes">
+ </jar>
+ </target>
+
+ <target name="common-war-compile" depends="common-init">
+ <javac srcdir="${sample.root}/src/main/java"
+ destdir="${sample.root}/target/classes"
+ debug="on"
+ source="1.5"
+ target="1.5">
+ <classpath refid="tuscany.path"/>
+ </javac>
+ <copy todir="${sample.root}/target/classes">
+ <fileset dir="${sample.root}/src/main/resources"/>
+ </copy>
+ <war destfile="${sample.war}" webxml="${sample.root}/src/main/webapp/WEB-INF/web.xml">
+ <fileset dir="${sample.root}/src/main/webapp"/>
+ <lib refid="tuscany.path"/>
+ <classes dir="${sample.root}/target/classes"/>
+ </war>
+ </target>
+
+ <target name="common-run-jse" depends="compile">
+ <java jar="${distro.root}/modules/tuscany-node-launcher-2.0-M4.jar"
+ fork="true"
+ inputstring="q">
+ <jvmarg value="-Djava.util.logging.config.file=${sample.root}/../../logging.properties"/>
+ <arg value="${sample.composite}"/>
+ <!-- would be good to have the node launcher run the first deployable
+ composite if this is not specified so I don't have to put it here -->
+ <arg value="${sample.jar}"/>
+ </java>
+ </target>
+
+ <target name="common-run-equinox" depends="compile">
+ <java jar="${distro.root}/modules/tuscany-node-launcher-equinox-2.0-M4.jar"
+ fork="true"
+ inputstring="q">
+ <jvmarg value="-Djava.util.logging.config.file=${sample.root}/../../logging.properties"/>
+ <arg value="${sample.composite}"/>
+ <!-- would be good to have the node launcher run the first deplyable
+ composite if this is not specified so I don't have to put it here -->
+ <arg value="${sample.jar}"/>
+ </java>
+ </target>
+
+ <target name="common-clean">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ </target>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/README b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/README
new file mode 100644
index 0000000000..7f76542622
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/README
@@ -0,0 +1,97 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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 -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-equinox.jar calculator.CalculatorClient
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-equinox.jar calculator.CalculatorClient
+
+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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/build.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/build.xml
new file mode 100644
index 0000000000..75c4839cfa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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-equinox" 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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.png b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.png
new file mode 100644
index 0000000000..995a57b1fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.svg b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.svg
new file mode 100644
index 0000000000..af34f07e04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/calculator.svg
@@ -0,0 +1,329 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator"
+ sodipodi:docname="calculator.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator\calculator.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="471.80491"
+ inkscape:cy="378.84265"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1054"
+ inkscape:window-height="721"
+ inkscape:window-x="59"
+ inkscape:window-y="79" />
+ <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(1,0,0,1.144214,0,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.86971939;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">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
+ id="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%" /></flowRegion><flowPara
+ id="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="594.75488"
+ y="209.73451"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(334.4498,10.22481)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Add</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">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 573.31867,232.29606 L 606.65371,232.29606 L 612.71462,245.42804 L 605.64356,257.54988 L 573.31867,257.54988 L 580.89482,245.42804 L 573.31867,232.29606 z "
+ id="path1913" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1917"
+ width="115.66247"
+ height="70.148659"
+ x="594.06543"
+ y="292.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1919"
+ transform="translate(333.7604,93.08188)"><flowRegion
+ id="flowRegion1921"><rect
+ id="rect1923"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1925">Subtract</flowPara><flowPara
+ id="flowPara1927">Service</flowPara><flowPara
+ id="flowPara1929">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 572.62924,315.15313 L 605.96428,315.15313 L 612.02519,328.28511 L 604.95413,340.40695 L 572.62924,340.40695 L 580.20539,328.28511 L 572.62924,315.15313 z "
+ id="path1931" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1933"
+ width="115.66247"
+ height="70.148659"
+ x="594.77979"
+ y="371.87729"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1935"
+ transform="translate(334.4747,172.3676)"><flowRegion
+ id="flowRegion1937"><rect
+ id="rect1939"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1941">Multiply</flowPara><flowPara
+ id="flowPara1943">Service</flowPara><flowPara
+ id="flowPara1945">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 573.34352,394.43884 L 606.67856,394.43884 L 612.73947,407.57082 L 605.66841,419.69266 L 573.34352,419.69266 L 580.91967,407.57082 L 573.34352,394.43884 z "
+ id="path1947" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1949"
+ width="115.66247"
+ height="70.148659"
+ x="596.20831"
+ y="452.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1951"
+ transform="translate(335.9032,253.0819)"><flowRegion
+ id="flowRegion1953"><rect
+ id="rect1955"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1957">Divide</flowPara><flowPara
+ id="flowPara1959">Service</flowPara><flowPara
+ id="flowPara1961">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 574.77209,475.15313 L 608.10713,475.15313 L 614.16804,488.28511 L 607.09698,500.40695 L 574.77209,500.40695 L 582.34824,488.28511 L 574.77209,475.15313 z "
+ id="path1963" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/pom.xml
new file mode 100644
index 0000000000..78c4f2c0e2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-equinox</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator Equinox</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-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-extensibility-equinox</artifactId>
+ <version>2.0-M4</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>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..7ca8fb04b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..84c98d7f70
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..031fa8b912
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..17fad7de6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..9450558145
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..b49e1da130
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.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 calculator;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+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 NodeLauncher launcher;
+ private static Node node;
+
+ public static void main(String[] args) throws Exception {
+ setUpBeforeClass();
+ tearDownAfterClass();
+ }
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ launcher = NodeLauncher.newInstance();
+ String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = launcher.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();
+ node.destroy();
+ }
+ if (launcher != null) {
+ launcher.destroy();
+ }
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..1ebd35b30a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/README b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/README
new file mode 100644
index 0000000000..332526d43a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/README
@@ -0,0 +1,97 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components and run it in a OSGi environment.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/build.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/build.xml
new file mode 100644
index 0000000000..46522211f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/pom.xml
new file mode 100644
index 0000000000..35a302e68b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-osgi</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator OSGi</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-feature-api</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</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></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..7ca8fb04b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java
new file mode 100644
index 0000000000..4408568629
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..afd5ea48fc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..c89043276e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..39f55ca31f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..9450558145
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..9d9b0a9ffb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.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 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();
+ node.destroy();
+ }
+ }
+
+ @Test
+ public void testDummy() throws Exception {
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/README b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/README
new file mode 100644
index 0000000000..07b6dd9713
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/README
@@ -0,0 +1,138 @@
+Calculator RMI Reference Sample
+===============================
+
+This sample illustrates the use of Tuscany RMI Binding to call reference
+services that are hosted as Java RMI services.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+If you just want to run it to see what happens open a command prompt, first
+navigate to the calculator-rmi-service sample and do:
+
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-service.jar calculator.CalculatorServer
+
+Now you have the server running you need to open another command prompt, navigate
+to this sample directory and do:
+
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-reference.jar calculator.CalculatorClient
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-reference.jar calculator.CalculatorClient
+
+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.
+
+This sample adds a number of classes to the basic calculator sample:
+
+calculator-rmi-reference/
+ src/
+ main/
+ java/
+ calculator/
+ CalculatorService.java - as calculator sample
+ AddService.java - as calculator sample
+ SubtractService.java - as calculator sample
+ MultipleService.java - as calculator sample
+ DivideService.java - as calculator sample
+ CalculatorClient.java - as calculator sample
+ CalculatorServiceImpl.java - calls the RMI service
+ that provides the target for the
+ RMI bindings in the composite
+ resources/
+ CalculatorRMIReference.composite - the SCA assembly for this sample
+ test/
+ java/
+ calculator/
+ CalculatorRMIReferenceTestCase.java - JUnit test case
+ CalculatorRMIServiceImpl.java - test RMI service to call
+ calculator-rmi-reference.png - a pictorial representation of the
+ .composite file
+ build.xml - the Ant build file for the client
+ pom.xml - the Maven build file
+
+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.
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built and run using Ant.
+
+The server provides an RMI server that the acts as a target for the SCA RMI
+bindings. Start a new console and use the following commands.
+
+cd calculator-rmi-service
+ant compile
+ant run
+
+This will run up the server and display the following.
+
+run:
+ [java] Starting of the SCA Calculator Application exposed as RMI Services...
+ [java] ...Press Enter to Exit...
+
+The client is very similar to the calculator sample. It starts the SCA runtime
+and calls each of the calculator operations. In doing this the RMI bindings
+make calls out to the RMI server you started in the previous step. Start
+a new console and use the following commands.
+
+cd calculator-rmi-reference
+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
+
+If you now return to the console window running the server and press enter the
+server should stop.
+
+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-rmi-reference
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running calculator.CalculatorRMIReferenceTestCase
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.308 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
+
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/build.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/build.xml
new file mode 100644
index 0000000000..e95ad1610b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/build.xml
@@ -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.
+-->
+
+<project name="binding-rmi-calculator-reference" default="run">
+
+ <property name="jar.name" value="sample-calculator-rmi-reference.jar" />
+ <property name="main.class" value="calculator.CalculatorClient" />
+
+ <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="../../modules">
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-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>
+
+ <target name="run" depends="compile">
+ <java classname="org.apache.tuscany.sca.launcher.LauncherMain"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="../../bin/launcher.jar"/>
+ </classpath>
+ <arg value="unmanaged"/>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+
+ <!-- We need to add a client component to trigger the calculation -->
+ <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="CalculatorRMIReference.composite"/>
+ <arg value="-config"/>
+ <arg value="../../features/configuration"/>
+ <arg value="-ttl"/>
+ <arg value="0"/>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+
+</project>
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.png b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.png
new file mode 100644
index 0000000000..8c76b77a9f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.svg b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.svg
new file mode 100644
index 0000000000..ba802e6717
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/calculator-rmi-reference.svg
@@ -0,0 +1,412 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator-rmi-reference"
+ sodipodi:docname="calculator-rmi-reference.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator-rmi-reference\calculator-rmi-reference.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="553.58838"
+ inkscape:cy="368.42498"
+ inkscape:document-units="px"
+ inkscape:current-layer="g2997"
+ inkscape:window-width="1134"
+ inkscape:window-height="721"
+ inkscape:window-x="1"
+ inkscape:window-y="105" />
+ <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.679966,0,0,1.144214,82.34853,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:2.2674253;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
+ <flowRoot
+ id="flowRoot2954"
+ xml:space="preserve"
+ transform="matrix(1.365843,0,0,1,-103.2086,0)"><flowRegion
+ id="flowRegion2956"><rect
+ y="212.66591"
+ x="281.42856"
+ height="61.42857"
+ width="170"
+ id="rect2958" /></flowRegion><flowPara
+ id="flowPara2960">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
+ id="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%" /></flowRegion><flowPara
+ id="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="773.32635"
+ y="331.87738"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(498.7355,125.2248)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Calculator</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">RMI</flowPara><flowPara
+ id="flowPara2004">Impl</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 567.77069,220.86752 L 630.65876,220.86752 L 642.09292,246.48812 L 628.75306,270.13795 L 567.77069,270.13795 L 582.06342,246.48812 L 567.77069,220.86752 z "
+ id="path1913" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1950"
+ transform="translate(301.0221,17.10977)"
+ style="font-size:11px;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="flowRegion1952"><rect
+ id="rect1954"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara1958">Add</flowPara><flowPara
+ id="flowPara1962">Reference</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 567.83889,304.45927 L 630.72696,304.45927 L 642.16112,330.07987 L 628.82126,353.7297 L 567.83889,353.7297 L 582.13162,330.07987 L 567.83889,304.45927 z "
+ id="path1964" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1966"
+ transform="translate(301.0903,100.7015)"
+ style="font-size:11px;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="flowRegion1968"><rect
+ id="rect1970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara1972">Subtract</flowPara><flowPara
+ id="flowPara1974">Reference</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 567.1246,382.31641 L 630.01267,382.31641 L 641.44683,407.93701 L 628.10697,431.58684 L 567.1246,431.58684 L 581.41733,407.93701 L 567.1246,382.31641 z "
+ id="path1976" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1978"
+ transform="translate(300.376,178.5587)"
+ style="font-size:11px;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="flowRegion1980"><rect
+ id="rect1982"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara1984">Multiply</flowPara><flowPara
+ id="flowPara1986">Reference</flowPara></flowRoot> <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 569.98175,459.45927 L 632.86982,459.45927 L 644.30398,485.07987 L 630.96412,508.7297 L 569.98175,508.7297 L 584.27448,485.07987 L 569.98175,459.45927 z "
+ id="path1988" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1990"
+ transform="translate(303.2332,255.7015)"
+ style="font-size:11px;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="flowRegion1992"><rect
+ id="rect1994"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara1996">Divide</flowPara><flowPara
+ id="flowPara1998">Reference</flowPara></flowRoot> <path
+ sodipodi:type="arc"
+ style="opacity:1;fill:#f19a9a;fill-opacity:1;stroke:#2e2424;stroke-width:1;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="path2000"
+ sodipodi:cx="736.78571"
+ sodipodi:cy="361.95163"
+ sodipodi:rx="39.642857"
+ sodipodi:ry="38.57143"
+ d="M 758.87546,329.92324 A 39.642857,38.57143 0 1 1 757.94075,329.33134"
+ sodipodi:start="5.3034219"
+ sodipodi:end="11.558474"
+ sodipodi:open="true"
+ transform="translate(-22.42857,4.142857)" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2006"
+ transform="translate(411.7392,139.0467)"><flowRegion
+ id="flowRegion2008"><rect
+ id="rect2010"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2016">RMI</flowPara><flowPara
+ id="flowPara2018">Registry</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 642.14286,246.23734 L 692.85714,333.3802"
+ id="path2027" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 640.71429,330.52305 L 677.14286,350.52305"
+ id="path2029" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 640.71429,408.3802 L 677.85714,382.66591"
+ id="path2031" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 645,484.80877 L 693.57143,400.52305"
+ id="path2033" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 753.57143,366.95163 L 773.57143,366.95163"
+ id="path2035" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2037"
+ transform="translate(385.3078,69.25256)"
+ style="font-size:11px;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="flowRegion2039"><rect
+ id="rect2041"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara2045">RMI</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot2059"
+ transform="translate(371.9396,116.0363)"
+ style="font-size:11px;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="flowRegion2061"><rect
+ id="rect2063"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara2065">RMI</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot2067"
+ transform="translate(366.9396,168.8935)"
+ style="font-size:11px;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="flowRegion2069"><rect
+ id="rect2071"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara2073">RMI</flowPara></flowRoot> <flowRoot
+ xml:space="preserve"
+ id="flowRoot2075"
+ transform="translate(376.9396,209.6077)"
+ style="font-size:11px;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="flowRegion2077"><rect
+ id="rect2079"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara2081">RMI</flowPara></flowRoot> </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/pom.xml
new file mode 100644
index 0000000000..01166487f9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-rmi-reference</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator RMI Reference</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-M4</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.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>calculator.CalculatorClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..a235e648c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..e14cc3dd13
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/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 uri = ContributionLocationHelper.getContributionLocation("CalculatorRMIReference.composite");
+ Contribution contribution = new Contribution("c1", uri);
+ Node node = NodeFactory.newInstance().createNode("CalculatorRMIReference.composite", contribution);
+ node.start();
+ CalculatorService calculatorService = node.getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // 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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..0f7dec116f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..bcfd8871b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..497dafd4fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..376b3e5bb9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite
new file mode 100644
index 0000000000..a5510954e0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java
new file mode 100644
index 0000000000..39d4b2fd28
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java
new file mode 100644
index 0000000000..d8ded42cb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/README b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/README
new file mode 100644
index 0000000000..144881134b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/README
@@ -0,0 +1,147 @@
+Calculator RMI Service Sample
+=============================
+
+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 samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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 -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-service.jar calculator.CalculatorServer
+
+Now you have the server running you need to open another command prompt, navigate
+to the calculator-rmi-reference sample directory and do:
+
+ant run
+
+OR if you don't have ant, on Windows do
+
+java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-rmi-reference.jar calculator.CalculatorClient
+
+and on *nix do
+
+java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-rmi-reference.jar calculator.CalculatorClient
+
+
+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.
+
+This sample adds a number of classes to the basic calculator sample:
+
+calculator-rmi-service/
+ src/
+ main/
+ java/
+ calculator/
+ CalculatorService.java - as calculator sample
+ CalculatorServiceImpl.java
+ AddService.java - as calculator sample
+ AddServiceImpl.java
+ SubtractService.java - as calculator sample
+ SubtractServiceImpl.java
+ MultiplyService.java - as calculator sample
+ MultiplyServiceImpl.java
+ DivideService.java - as calculator sample
+ DivideServiceImpl.java
+ CalculatorClient.java - (Not currently used) Uses the
+ java naming service to
+ look up the Calculator RMI service.
+ It then calls add, subtract, multiple
+ and divide methods on the service
+ CalculatorServer.java - starts the SCA Runtime and deploys
+ the CalculatorRMIServer.composite.
+ In doing this the SCA RMI binding
+ acts to expose the CalculatorService
+ over RMI.
+ resources/
+ CalculatorRMIServer.composite - the SCA assembly for this sample
+ test/
+ java/
+ calculator/
+ CalculatorRMIServerTestCase.java - JUnit test case
+ calculator-rmi-service.png - a pictorial representation of the
+ .composite file
+ build.xml - the Ant build file for the server
+ pom.xml - the Maven build file
+
+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.
+
+Building And Running The Sample Using Ant
+-----------------------------------------
+With the binary distribution the sample can be built and run using Ant. Two
+build files are used to support client and server functions.
+
+The server starts the SCA runtime and loads the SCA calculator application
+which exposes an RMI service. Start a new console and use the following
+commands.
+
+cd calculator-rmi-service
+ant compile
+ant run
+
+This will run up the server and display the following.
+
+run:
+ [java] Starting of the SCA Calculator Application exposed as RMI Services...
+ [java] ...Press Enter to Exit...
+
+The client is very similar to the calculator sample
+
+It locates the RMI service that the SCA runtime is exposing and calls each of
+the calculator operations. Start a new console and use the following commands.
+
+cd calculator-rmi-reference
+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
+
+If you now return to the console window running the server and press enter the
+server should stop.
+
+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-rmi-service
+mvn
+
+You should see the following output from the test phase.
+
+-------------------------------------------------------
+ T E S T S
+-------------------------------------------------------
+Running calculator.CalculatorRMIServerTestCase
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.819 sec
+
+Results :
+
+Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
+
+This shows that the Junit test cases have run successfully.
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/build.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/build.xml
new file mode 100644
index 0000000000..a0889ccc8a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/build.xml
@@ -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.
+-->
+
+<project name="binding-rmi-calculator-service" default="run">
+
+ <property name="jar.name" value="sample-calculator-rmi-service.jar" />
+ <property name="main.class" value="calculator.CalculatorClient" />
+
+ <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="../../modules">
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-api-*.jar" />
+ </fileset>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes">
+ </jar>
+ </target>
+
+ <target name="run" depends="compile">
+ <java classname="org.apache.tuscany.sca.launcher.LauncherMain"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="../../bin/launcher.jar"/>
+ </classpath>
+ <arg value="target/${jar.name}"/>
+ </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="-config"/>
+ <arg value="../../features/configuration"/>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+
+
+</project>
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.png b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.png
new file mode 100644
index 0000000000..574f5eb14b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.svg b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.svg
new file mode 100644
index 0000000000..9253110f98
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/calculator-rmi-service.svg
@@ -0,0 +1,330 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator-rmi-service"
+ sodipodi:docname="calculator-rmi-service.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator-rmi-service\calculator-rmi-service.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="471.80491"
+ inkscape:cy="378.84265"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1054"
+ inkscape:window-height="721"
+ inkscape:window-x="186"
+ inkscape:window-y="165" />
+ <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(1,0,0,1.144214,0,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.86971939;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">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-size:11px;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="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:11px;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="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara><flowPara
+ id="flowPara1950">(RMI)</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="594.75488"
+ y="209.73451"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(334.4498,10.22481)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Add</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">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 573.31867,232.29606 L 606.65371,232.29606 L 612.71462,245.42804 L 605.64356,257.54988 L 573.31867,257.54988 L 580.89482,245.42804 L 573.31867,232.29606 z "
+ id="path1913" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1917"
+ width="115.66247"
+ height="70.148659"
+ x="594.06543"
+ y="292.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1919"
+ transform="translate(333.7604,93.08188)"><flowRegion
+ id="flowRegion1921"><rect
+ id="rect1923"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1925">Subtract</flowPara><flowPara
+ id="flowPara1927">Service</flowPara><flowPara
+ id="flowPara1929">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 572.62924,315.15313 L 605.96428,315.15313 L 612.02519,328.28511 L 604.95413,340.40695 L 572.62924,340.40695 L 580.20539,328.28511 L 572.62924,315.15313 z "
+ id="path1931" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1933"
+ width="115.66247"
+ height="70.148659"
+ x="594.77979"
+ y="371.87729"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1935"
+ transform="translate(334.4747,172.3676)"><flowRegion
+ id="flowRegion1937"><rect
+ id="rect1939"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1941">Multiply</flowPara><flowPara
+ id="flowPara1943">Service</flowPara><flowPara
+ id="flowPara1945">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 573.34352,394.43884 L 606.67856,394.43884 L 612.73947,407.57082 L 605.66841,419.69266 L 573.34352,419.69266 L 580.91967,407.57082 L 573.34352,394.43884 z "
+ id="path1947" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1949"
+ width="115.66247"
+ height="70.148659"
+ x="596.20831"
+ y="452.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1951"
+ transform="translate(335.9032,253.0819)"><flowRegion
+ id="flowRegion1953"><rect
+ id="rect1955"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1957">Divide</flowPara><flowPara
+ id="flowPara1959">Service</flowPara><flowPara
+ id="flowPara1961">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 574.77209,475.15313 L 608.10713,475.15313 L 614.16804,488.28511 L 607.09698,500.40695 L 574.77209,500.40695 L 582.34824,488.28511 L 574.77209,475.15313 z "
+ id="path1963" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/pom.xml
new file mode 100644
index 0000000000..f3f8ed5644
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator-rmi-service</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator RMI Service</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rmi-runtime</artifactId>
+ <version>2.0-M4</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>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..a235e648c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..8b6fe066a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..2b99485b68
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java
new file mode 100644
index 0000000000..b77015bcae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.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 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;
+
+/**
+ * A claculator service server. Starts up the SCA runtime which
+ * will start listening for RMI service requests.
+ */
+public class CalculatorServer {
+ public static void main(String[] args) throws Exception {
+ System.out.println("Starting of the SCA Calculator Application exposed as RMI Services...");
+ String uri = ContributionLocationHelper.getContributionLocation("CalculatorRMIServer.composite");
+ Contribution contribution = new Contribution("c1", uri);
+ Node node = NodeFactory.newInstance().createNode("CalculatorRMIServer.composite", contribution);
+ node.start();
+ System.out.println("... Press Enter to Exit...");
+ System.in.read();
+ node.stop();
+ System.out.println("Exited...");
+ System.exit(0);
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..3c0375924f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..bcfd8871b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..497dafd4fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..f7ac0b7287
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..b7dca792b2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..376b3e5bb9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..77b128ab8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite
new file mode 100644
index 0000000000..02614ad6e1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..27a1ee74e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java
new file mode 100644
index 0000000000..0e352db9bb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator-rmi-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/tags/java/sca/2.0-M4-RC2/samples/calculator/README b/tags/java/sca/2.0-M4-RC2/samples/calculator/README
new file mode 100644
index 0000000000..56c22d9c89
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/README
@@ -0,0 +1,97 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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 -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient
+
+and on *nix do
+
+java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator.jar calculator.CalculatorClient
+
+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/tags/java/sca/2.0-M4-RC2/samples/calculator/build.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator/build.xml
new file mode 100644
index 0000000000..4411cae659
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/build.xml
@@ -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.
+-->
+
+<project name="calculator" default="run">
+
+ <property name="jar.name" value="sample-calculator.jar" />
+ <property name="main.class" value="calculator.CalculatorClient" />
+
+ <target name="compile" depends="init">
+ <javac srcdir="src/main/java" destdir="target/classes" debug="on" source="1.5" target="1.5">
+ <classpath>
+ <fileset dir="../../modules">
+ <include name="tuscany-sca-api-*.jar" />
+ <include name="tuscany-node-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>
+
+ <target name="init">
+ <delete quiet="true" includeemptydirs="true">
+ <fileset dir="target"/>
+ </delete>
+ <mkdir dir="target/classes"/>
+ </target>
+
+ <target name="run" depends="compile">
+ <java classname="org.apache.tuscany.sca.launcher.LauncherMain"
+ fork="true"
+ failonerror="true">
+ <classpath>
+ <pathelement location="../../bin/launcher.jar"/>
+ </classpath>
+ <arg value="unmanaged"/>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+
+</project>
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.png b/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.png
new file mode 100644
index 0000000000..995a57b1fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.svg b/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.svg
new file mode 100644
index 0000000000..0615925c50
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/calculator.svg
@@ -0,0 +1,329 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator"
+ sodipodi:docname="calculator.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator\calculator.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="471.80491"
+ inkscape:cy="378.84265"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1054"
+ inkscape:window-height="721"
+ inkscape:window-x="59"
+ inkscape:window-y="79" />
+ <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(1,0,0,1.144214,0,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.86971939;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">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
+ id="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%" /></flowRegion><flowPara
+ id="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="594.75488"
+ y="209.73451"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(334.4498,10.22481)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Add</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">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 573.31867,232.29606 L 606.65371,232.29606 L 612.71462,245.42804 L 605.64356,257.54988 L 573.31867,257.54988 L 580.89482,245.42804 L 573.31867,232.29606 z "
+ id="path1913" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1917"
+ width="115.66247"
+ height="70.148659"
+ x="594.06543"
+ y="292.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1919"
+ transform="translate(333.7604,93.08188)"><flowRegion
+ id="flowRegion1921"><rect
+ id="rect1923"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1925">Subtract</flowPara><flowPara
+ id="flowPara1927">Service</flowPara><flowPara
+ id="flowPara1929">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 572.62924,315.15313 L 605.96428,315.15313 L 612.02519,328.28511 L 604.95413,340.40695 L 572.62924,340.40695 L 580.20539,328.28511 L 572.62924,315.15313 z "
+ id="path1931" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1933"
+ width="115.66247"
+ height="70.148659"
+ x="594.77979"
+ y="371.87729"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1935"
+ transform="translate(334.4747,172.3676)"><flowRegion
+ id="flowRegion1937"><rect
+ id="rect1939"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1941">Multiply</flowPara><flowPara
+ id="flowPara1943">Service</flowPara><flowPara
+ id="flowPara1945">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 573.34352,394.43884 L 606.67856,394.43884 L 612.73947,407.57082 L 605.66841,419.69266 L 573.34352,419.69266 L 580.91967,407.57082 L 573.34352,394.43884 z "
+ id="path1947" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1949"
+ width="115.66247"
+ height="70.148659"
+ x="596.20831"
+ y="452.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1951"
+ transform="translate(335.9032,253.0819)"><flowRegion
+ id="flowRegion1953"><rect
+ id="rect1955"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1957">Divide</flowPara><flowPara
+ id="flowPara1959">Service</flowPara><flowPara
+ id="flowPara1961">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 574.77209,475.15313 L 608.10713,475.15313 L 614.16804,488.28511 L 607.09698,500.40695 L 574.77209,500.40695 L 582.34824,488.28511 L 574.77209,475.15313 z "
+ id="path1963" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator/pom.xml
new file mode 100644
index 0000000000..8c0a29be3b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Calculator</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</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.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>calculator.CalculatorClient</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..bb75bb2337
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..03fc56ceb3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/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.apache.tuscany.sca.node.Client;
+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 {
+
+ Node node = NodeFactory.newInstance().createNode();
+
+ node.start();
+
+ CalculatorService calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+
+ // 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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..031fa8b912
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..fc53393d23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..b1250ed9f2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..11f68c66e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..30e59bf668
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..f67b212d99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..27a1ee74e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/200903"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:Calculator"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..73c7d872b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/calculator/src/test/java/calculator/CalculatorTestCase.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 org.apache.tuscany.sca.node.Client;
+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 CalculatorTestCase{
+ private static Node node;
+ private static CalculatorService calculatorService;
+
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ NodeFactory factory = NodeFactory.newInstance();
+ String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = factory.createNode("Calculator.composite", new Contribution("calculator", contribution)).start();
+ // node = factory.createNode().start();
+
+ calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testCalculator() throws Exception {
+ // Calculate
+ assertEquals(calculatorService.add(3, 2), 5.0, 0);
+ assertEquals(calculatorService.subtract(3, 2), 1.0, 0);
+ assertEquals(calculatorService.multiply(3, 2), 6.0, 0);
+ assertEquals(calculatorService.divide(3, 2), 1.5, 0);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/LICENSE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..82a803e3a6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/NOTICE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml
new file mode 100644
index 0000000000..99845257ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml
new file mode 100644
index 0000000000..f6b5f4690e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml
new file mode 100644
index 0000000000..322d4daf2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml
new file mode 100644
index 0000000000..b9ca777bd8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..72e2c339f1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType
@@ -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.
+-->
+<componentType xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ 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"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="SubtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="MultiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+ <service name="DivideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite
new file mode 100644
index 0000000000..253f7d0df1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml
new file mode 100644
index 0000000000..1472f5a976
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/README b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/README
new file mode 100644
index 0000000000..9e616c1f50
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/README
@@ -0,0 +1,183 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.4.0-v20080605-1900.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.4.0-v20080605-1900.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 181
+
+osgi> start 181
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Starting file:./target/sample-dosgi-calculator-operations.jar [181]
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.AddService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.SubtractService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.MultiplyService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.DivideService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator get
+Bundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi.operations
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi.operations
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.node.impl.NodeFactoryImpl configu
+reNode
+INFO: Loading contribution: bundleentry://181/
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(AddService/AddService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/AddService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(SubtractService/SubtractService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/SubtractService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(MultiplyService/MultiplyService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/MultiplyService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(DivideService/DivideService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/DivideService
+
+osgi>
+
+To stop the bundle:
+
+osgi> stop 181
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi.operations
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(AddService/AddService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/AddService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(SubtractService/SubtractService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/SubtractService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(MultiplyService/MultiplyService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/MultiplyService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(DivideService/DivideService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/DivideService
+Jun 22, 2009 2:09:48 PM calculator.dosgi.operations.impl.OperationsActivator sto
+p
+INFO: Stopping file:./target/sample-dosgi-calculator-operations.jar [181]
+
+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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/pom.xml
new file mode 100644
index 0000000000..883eb22bbe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/pom.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-calculator-operations</artifactId>
+ <name>Apache Tuscany SCA Distributed OSGi (RFC 119) Caculator Operations Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-M4</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.5</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></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..da2ce9063a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..16a33f4f65
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:OperationsComposite" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..cd92989da1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
new file mode 100644
index 0000000000..02007c385c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
new file mode 100644
index 0000000000..49c5aab041
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/LICENSE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..542b53b085
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/NOTICE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml
new file mode 100644
index 0000000000..fd834e12ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/calculator-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType
new file mode 100644
index 0000000000..769bcdd14d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/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/200903"
+ 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 -->
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </service>
+
+ <!-- The reference elment defines an SCA proxy to a remote OSGi service -->
+ <reference name="addService">
+ <interface.java interface="calculator.dosgi.operations.AddService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="subtractService">
+ <interface.java interface="calculator.dosgi.operations.SubtractService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="multiplyService">
+ <interface.java interface="calculator.dosgi.operations.MultiplyService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+ <reference name="divideService">
+ <interface.java interface="calculator.dosgi.operations.DivideService"/>
+ <t:osgi.property name="prop1">1</t:osgi.property>
+ <t:osgi.property name="prop2">ABC</t:osgi.property>
+ </reference>
+
+</componentType>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite
new file mode 100644
index 0000000000..481fd67e09
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/README b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/README
new file mode 100644
index 0000000000..374c0f0a8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/README
@@ -0,0 +1,155 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.4.0-v20080605-1900.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.4.0-v20080605-1900.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.jar
+Bundle id is 181
+
+osgi> start 181
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Starting file:./target/sample-dosgi-calculator.jar [181]
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Registering calculator.dosgi.CalculatorService
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator getBundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.node.impl.NodeFactoryImpl configu
+reNode
+INFO: Loading contribution: bundleentry://181/
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = CalculatorComponent#serv
+ice-binding(CalculatorService/CalculatorService)
+2009-06-22 13:37:21.953::INFO: jetty-6.1.x
+2009-06-22 13:37:21.953::INFO: Started SelectChannelConnector@0.0.0.0:8086
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.http.jetty.JettyServer addServlet
+Mapping
+INFO: Added Servlet mapping: http://rfengt61p:8086/CalculatorService
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(addService/addService) Target = Endpoint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(subtractService/subtractService) Target = Endp
+oint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(multiplyService/multiplyService) Target = Endp
+oint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(divideService/divideService) Target = Endpoint
+:
+
+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 181
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = CalculatorComponent#s
+ervice-binding(CalculatorService/CalculatorService)
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.http.jetty.JettyServer removeServ
+letMapping
+INFO: Removed Servlet mapping: /CalculatorService
+Jun 22, 2009 1:39:09 PM calculator.dosgi.impl.CalculatorActivator stop
+INFO: Stopping file:./target/sample-dosgi-calculator.jar [181]
+
+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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/dosgi-calculator.png b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/dosgi-calculator.png
new file mode 100644
index 0000000000..805baa54d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/dosgi-calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/pom.xml
new file mode 100644
index 0000000000..9865570638
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-calculator</artifactId>
+ <name>Apache Tuscany SCA Distributed OSGi (RFC 119) Caculator Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-M4</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.5</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></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..6b42645f69
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..a9ea37585a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
new file mode 100644
index 0000000000..a4fc52694e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java
new file mode 100644
index 0000000000..a813dfb6f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java
new file mode 100644
index 0000000000..955e386ad8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b14b3516f6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:c="http://calculator.dosgi">
+ <deployable composite="c:CalculatorComposite" />
+</contribution>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
new file mode 100644
index 0000000000..565a314d85
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..4dd713ecef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-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".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/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..99e0da9f97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/LICENSE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..cea4e2ff79
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/NOTICE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml
new file mode 100644
index 0000000000..99845257ff
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml
new file mode 100644
index 0000000000..f6b5f4690e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml
new file mode 100644
index 0000000000..322d4daf2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml
new file mode 100644
index 0000000000..b9ca777bd8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml
new file mode 100644
index 0000000000..b00f05ad2d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml
new file mode 100644
index 0000000000..1472f5a976
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/README b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/README
new file mode 100644
index 0000000000..9e616c1f50
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/README
@@ -0,0 +1,183 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.4.0-v20080605-1900.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.4.0-v20080605-1900.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 181
+
+osgi> start 181
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Starting file:./target/sample-dosgi-calculator-operations.jar [181]
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.AddService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.SubtractService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.MultiplyService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator sta
+rt
+INFO: Registering calculator.dosgi.operations.DivideService
+Jun 22, 2009 2:09:21 PM calculator.dosgi.operations.impl.OperationsActivator get
+Bundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi.operations
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi.operations
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.node.impl.NodeFactoryImpl configu
+reNode
+INFO: Loading contribution: bundleentry://181/
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(AddService/AddService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/AddService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(SubtractService/SubtractService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/SubtractService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(MultiplyService/MultiplyService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/MultiplyService
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = OperationsComponent#serv
+ice-binding(DivideService/DivideService)
+Jun 22, 2009 2:09:21 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost registerS
+ervice
+INFO: RMI service registered: rmi://localhost:8085/DivideService
+
+osgi>
+
+To stop the bundle:
+
+osgi> stop 181
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi.operations
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(AddService/AddService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/AddService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(SubtractService/SubtractService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/SubtractService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(MultiplyService/MultiplyService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/MultiplyService
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = OperationsComponent#s
+ervice-binding(DivideService/DivideService)
+Jun 22, 2009 2:09:48 PM org.apache.tuscany.sca.host.rmi.DefaultRMIHost unregiste
+rService
+INFO: RMI service unregistered: rmi://localhost:8085/DivideService
+Jun 22, 2009 2:09:48 PM calculator.dosgi.operations.impl.OperationsActivator sto
+p
+INFO: Stopping file:./target/sample-dosgi-calculator-operations.jar [181]
+
+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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/pom.xml
new file mode 100644
index 0000000000..71cd14113c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/pom.xml
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-dynamic-calculator-operations</artifactId>
+ <name>Apache Tuscany SCA OSGi RemoteService Dynamic Caculator Operations Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-M4</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.5</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></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java
new file mode 100644
index 0000000000..66b2977241
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java
new file mode 100644
index 0000000000..a3c21b2b96
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..7922d2d392
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java
new file mode 100644
index 0000000000..f75cc6444e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java
new file mode 100644
index 0000000000..4bbe83b14f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..cd92989da1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java
new file mode 100644
index 0000000000..02007c385c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java
new file mode 100644
index 0000000000..eee64bf86f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/LICENSE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/LICENSE
new file mode 100644
index 0000000000..6e529a25c4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..6ce24a4a32
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/NOTICE b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/NOTICE
new file mode 100644
index 0000000000..51042eab05
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml
new file mode 100644
index 0000000000..fd834e12ef
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml
new file mode 100644
index 0000000000..5daaa59aae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml
new file mode 100644
index 0000000000..ac73ea98f0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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 -->
+<service-descriptions xmlns="http://www.osgi.org/xmlns/sd/v1.0.0"
+ xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200903"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1">
+ <!-- Describe a remote OSGi service -->
+ <service-description>
+ <provide interface="calculator.dosgi.operations.AddService" />
+ <property name="remote.exported.intents"></property>
+ <property name="remote.configs.supported">org.osgi.sca</property>
+ <property name="sca.reference">
+ addService
+ </property>
+ <property name="org.osgi.sca.bindings">{http://sample}Add</property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.SubtractService" />
+ <property name="remote.exported.intents"></property>
+ <property name="remote.configs.supported">org.osgi.sca</property>
+ <property name="sca.reference">
+ subtractService
+ </property>
+ <property name="org.osgi.sca.bindings">{http://sample}Subtract</property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.MultiplyService" />
+ <property name="remote.exported.intents"></property>
+ <property name="remote.configs.supported">org.osgi.sca</property>
+ <property name="sca.reference">
+ multiplyService
+ </property>
+ <property name="org.osgi.sca.bindings">{http://sample}Multiply</property>
+ </service-description>
+ <service-description>
+ <provide interface="calculator.dosgi.operations.DivideService" />
+ <property name="remote.exported.intents"></property>
+ <property name="remote.configs.supported">org.osgi.sca</property>
+ <property name="sca.reference">
+ divideService
+ </property>
+ <property name="org.osgi.sca.bindings">{http://sample}Divide</property>
+ </service-description>
+</service-descriptions> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml
new file mode 100644
index 0000000000..878ef9c18e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/README b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/README
new file mode 100644
index 0000000000..374c0f0a8b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/README
@@ -0,0 +1,155 @@
+Distributed OSGi Calculator Sample
+==================================
+This sample implements a distributed calculator using Distributed OSGi (RFC 119) over SCA.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+On Windows, run
+java -jar ..\..\modules\osgi-3.4.0-v20080605-1900.jar -configuration ..\..\features\configuration -clean -console
+
+On *Unix, run
+java -jar ../../modules/osgi-3.4.0-v20080605-1900.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.jar
+Bundle id is 181
+
+osgi> start 181
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Starting file:./target/sample-dosgi-calculator.jar [181]
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator start
+INFO: Registering calculator.dosgi.CalculatorService
+Jun 22, 2009 1:37:21 PM calculator.dosgi.impl.CalculatorActivator getBundle
+INFO: calculator.dosgi.operations.AddService is loaded by bundle: calculator.dos
+gi
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.node.impl.NodeImpl start
+INFO: Starting node: calculator.dosgi
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.node.impl.NodeFactoryImpl configu
+reNode
+INFO: Loading contribution: bundleentry://181/
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpoint
+INFO: EndpointRegistry: Add endpoint - Endpoint: URI = CalculatorComponent#serv
+ice-binding(CalculatorService/CalculatorService)
+2009-06-22 13:37:21.953::INFO: jetty-6.1.x
+2009-06-22 13:37:21.953::INFO: Started SelectChannelConnector@0.0.0.0:8086
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.http.jetty.JettyServer addServlet
+Mapping
+INFO: Added Servlet mapping: http://rfengt61p:8086/CalculatorService
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(addService/addService) Target = Endpoint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(subtractService/subtractService) Target = Endp
+oint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(multiplyService/multiplyService) Target = Endp
+oint:
+Jun 22, 2009 1:37:21 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry addEndpointReference
+INFO: EndpointRegistry: Add endpoint reference - Endpoint Reference: URI = Calc
+ulatorComponent#reference-binding(divideService/divideService) Target = Endpoint
+:
+
+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 181
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.node.impl.NodeImpl stop
+INFO: Stopping node: calculator.dosgi
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.endpoint.tribes.ReplicatedEndpoin
+tRegistry removeEndpoint
+INFO: EndpointRegistry: Remove endpoint - Endpoint: URI = CalculatorComponent#s
+ervice-binding(CalculatorService/CalculatorService)
+Jun 22, 2009 1:39:09 PM org.apache.tuscany.sca.http.jetty.JettyServer removeServ
+letMapping
+INFO: Removed Servlet mapping: /CalculatorService
+Jun 22, 2009 1:39:09 PM calculator.dosgi.impl.CalculatorActivator stop
+INFO: Stopping file:./target/sample-dosgi-calculator.jar [181]
+
+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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/dosgi-calculator.png b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/dosgi-calculator.png
new file mode 100644
index 0000000000..805baa54d2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/dosgi-calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/pom.xml
new file mode 100644
index 0000000000..53063357a2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/pom.xml
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * 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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>sample-dosgi-dynamic-calculator</artifactId>
+ <name>Apache Tuscany SCA OSGi RemoteService Dynamic Caculator Sample</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-ejava</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-webservice</artifactId>
+ <version>2.0-M4</version>
+ <type>pom</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-launcher-equinox</artifactId>
+ <version>2.0-M4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl-osgi</artifactId>
+ <version>2.0-M4</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.5</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></configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java
new file mode 100644
index 0000000000..cc562b7c2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java
new file mode 100644
index 0000000000..6228afcd53
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java
new file mode 100644
index 0000000000..5f9db16ca9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..a9ea37585a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java
new file mode 100644
index 0000000000..971500782f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java
new file mode 100644
index 0000000000..49b8a1c0bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java
new file mode 100644
index 0000000000..f4e59d12ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java
new file mode 100644
index 0000000000..bfb9b820f7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java
new file mode 100644
index 0000000000..a4fc52694e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java
new file mode 100644
index 0000000000..a813dfb6f3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java
new file mode 100644
index 0000000000..955e386ad8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java
new file mode 100644
index 0000000000..565a314d85
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java
new file mode 100644
index 0000000000..4015c7bbc2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java b/tags/java/sca/2.0-M4-RC2/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java
new file mode 100644
index 0000000000..99e0da9f97
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/README b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/README
new file mode 100644
index 0000000000..bf5f500ef3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/README
@@ -0,0 +1,151 @@
+Hello World BPEL Sample
+======================================
+This sample demonstrates an SCA service implemented by a BPEL process.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/build.xml b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/build.xml
new file mode 100644
index 0000000000..008953e63b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.png b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.png
new file mode 100644
index 0000000000..5f53a3c5d1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.svg b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/helloworld-bpel.svg
new file mode 100644
index 0000000000..5a98f1a07c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/pom.xml
new file mode 100644
index 0000000000..611c632bf2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-helloworld-bpel</artifactId>
+ <name>Apache Tuscany SCA Sample HelloWorld BPEL</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-java-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-bpel-runtime</artifactId>
+ <version>2.0-M4</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.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.3.2</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.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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java
new file mode 100644
index 0000000000..e2d69eddf6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.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.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/**
+ * Simple BPEL sample application invoking a helloworld
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELClient {
+ public static void main(String[] args) throws Exception {
+
+ Node node = NodeFactory.newInstance().createNode();
+ node.start();
+
+ Hello bpelService = node.getService(Hello.class, "BPELHelloWorldComponent");
+
+ String result = bpelService.hello("Hello");
+ System.out.println(result);
+
+ node.stop();
+
+ System.exit(0);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java
new file mode 100644
index 0000000000..dbd3854d7c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..b95468acd8
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ xmlns:sample="http://bpel">
+ <deployable composite="sample:bpel"/>
+</contribution> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..19afe61fd3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/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: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($myVar.TestPart/test:message/text(), ' World')</from>
+ <to variable="tmpVar"/>
+ </copy>
+ <!--
+ <copy>
+ <from>
+ <literal>
+ <test:hello>
+ <test:message>$tmpVar</test:message>
+ </test:hello>
+ </literal>
+ </from>
+ <to variable="myVar" part="TestPart"/>
+ </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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.composite b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.composite
new file mode 100644
index 0000000000..603cc17af9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ targetNamespace="http://bpel"
+ xmlns:hns="http://tuscany.apache.org/implementation/bpel/example/helloworld"
+ name="bpel">
+
+ <component name="BPELHelloWorldComponent">
+ <implementation.bpel process="hns:HelloWorld"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..46cf381577
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..8649a71550
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java
new file mode 100644
index 0000000000..12e40d334b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.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 helloworld;
+
+import junit.framework.Assert;
+
+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 service
+ *
+ * @version $Rev$ $Date$
+ */
+public class BPELHelloWorldTestCase {
+
+ private static Node node;
+ private static Hello bpelService;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @BeforeClass
+ public static void setUp() throws Exception {
+
+ node = NodeFactory.newInstance().createNode();
+ node.start();
+
+ bpelService = node.getService(Hello.class, "BPELHelloWorldComponent");
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @AfterClass
+ public static void tearDown() throws Exception {
+ node.stop();
+ }
+
+ @Test
+ public void testInvoke() throws Exception {
+ String response = bpelService.hello("Hello");
+ Assert.assertEquals("Hello World", response);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/README b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/README
new file mode 100644
index 0000000000..28eccbdebb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/README
@@ -0,0 +1,96 @@
+Calculator Sample
+=================
+This sample implements a simple calculator using SCA components.
+
+The README in the samples directory (the directory above this) provides
+general instructions about building and running samples. Take a look there
+first.
+
+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-implementation-java-calculator.jar
+and on *nix do
+
+java -jar ../../features/tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ../../features/configuration/ -ttl 0 target/sample-implementation-java-calculator.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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/build.xml b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/build.xml
new file mode 100644
index 0000000000..050540a93a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/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="implementation-java-calculator" default="run"> <!-- could dertmine the same name autmatically -->
+
+ <property name="jar.name" value="sample-implementation-java-calculator.jar" />
+
+ <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>
+ <pathelement location="../../modules/tuscany-sca-api-2.0-M4.jar"/>
+ </classpath>
+ </javac>
+ <copy todir="target/classes">
+ <fileset dir="src/main/resources"/>
+ </copy>
+ <jar destfile="target/${jar.name}" basedir="target/classes"/>
+ </target>
+
+ <target name="run" depends="compile">
+ <java classname="org.apache.tuscany.sca.launcher.LauncherMain"
+ fork="true"
+ inputstring="q"
+ failonerror="true">
+ <classpath>
+ <pathelement location="../../bin/launcher.jar"/>
+ </classpath>
+ <arg value="target/${jar.name}"/>
+ </java>
+ </target>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.png b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.png
new file mode 100644
index 0000000000..995a57b1fd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.png
Binary files differ
diff --git a/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.svg b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.svg
new file mode 100644
index 0000000000..af34f07e04
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/calculator.svg
@@ -0,0 +1,329 @@
+<?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.44"
+ sodipodi:docbase="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator"
+ sodipodi:docname="calculator.svg"
+ version="1.0"
+ inkscape:export-filename="C:\simon\Projects\Tuscany\java\java-head\sca\samples\calculator\calculator.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="471.80491"
+ inkscape:cy="378.84265"
+ inkscape:document-units="px"
+ inkscape:current-layer="layer1"
+ inkscape:window-width="1054"
+ inkscape:window-height="721"
+ inkscape:window-x="59"
+ inkscape:window-y="79" />
+ <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(1,0,0,1.144214,0,-27.53557)">
+ <rect
+ rx="15.307091"
+ ry="12.692303"
+ y="192.00233"
+ x="258.31146"
+ height="299.99988"
+ width="495.71429"
+ id="rect2067"
+ style="opacity:1;fill:#90baf4;fill-opacity:1;stroke:#060000;stroke-width:1.86971939;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">Calculator</flowPara></flowRoot> </g>
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:1.9999994;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect2988"
+ width="115.66247"
+ height="191.57716"
+ x="339.91632"
+ y="262.1673"
+ rx="6.9961648"
+ ry="15.892869" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2966"
+ transform="translate(79.61125,62.65764)"><flowRegion
+ id="flowRegion2968"><rect
+ id="rect2970"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara2972">Calculator</flowPara><flowPara
+ id="flowPara1895">Service</flowPara><flowPara
+ id="flowPara1897">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 322.76581,342.58603 L 356.10085,342.58603 L 362.16176,355.71801 L 355.0907,367.83985 L 322.76581,367.83985 L 330.34196,355.71801 L 322.76581,342.58603 z "
+ id="path3017" />
+ <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.01809,321.46204 L 471.00147,321.46204 L 478.27117,334.59402 L 469.78986,346.71586 L 431.01809,346.71586 L 440.10523,334.59402 L 431.01809,321.46204 z "
+ id="path3019" />
+ <path
+ style="fill:#5b9d05;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:1.00000024px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 223.15923,328.61046 L 282.4833,328.61046 L 293.26948,355.48529 L 280.68561,380.29286 L 223.15923,380.29286 L 236.64198,355.48529 L 223.15923,328.61046 z "
+ id="path1883" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1885"
+ transform="translate(-46.16225,128.7269)"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%"><flowRegion
+ id="flowRegion1887"><rect
+ id="rect1889"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-family:Bitstream Vera Sans;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:11;text-anchor:start;text-align:start;writing-mode:lr;line-height:125%" /></flowRegion><flowPara
+ id="flowPara1891">Calculator</flowPara><flowPara
+ id="flowPara1893">Service</flowPara></flowRoot> <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1899"
+ width="115.66247"
+ height="70.148659"
+ x="594.75488"
+ y="209.73451"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1901"
+ transform="translate(334.4498,10.22481)"><flowRegion
+ id="flowRegion1903"><rect
+ id="rect1905"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1907">Add</flowPara><flowPara
+ id="flowPara1909">Service</flowPara><flowPara
+ id="flowPara1911">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 573.31867,232.29606 L 606.65371,232.29606 L 612.71462,245.42804 L 605.64356,257.54988 L 573.31867,257.54988 L 580.89482,245.42804 L 573.31867,232.29606 z "
+ id="path1913" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1917"
+ width="115.66247"
+ height="70.148659"
+ x="594.06543"
+ y="292.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1919"
+ transform="translate(333.7604,93.08188)"><flowRegion
+ id="flowRegion1921"><rect
+ id="rect1923"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1925">Subtract</flowPara><flowPara
+ id="flowPara1927">Service</flowPara><flowPara
+ id="flowPara1929">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 572.62924,315.15313 L 605.96428,315.15313 L 612.02519,328.28511 L 604.95413,340.40695 L 572.62924,340.40695 L 580.20539,328.28511 L 572.62924,315.15313 z "
+ id="path1931" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1933"
+ width="115.66247"
+ height="70.148659"
+ x="594.77979"
+ y="371.87729"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1935"
+ transform="translate(334.4747,172.3676)"><flowRegion
+ id="flowRegion1937"><rect
+ id="rect1939"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1941">Multiply</flowPara><flowPara
+ id="flowPara1943">Service</flowPara><flowPara
+ id="flowPara1945">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 573.34352,394.43884 L 606.67856,394.43884 L 612.73947,407.57082 L 605.66841,419.69266 L 573.34352,419.69266 L 580.91967,407.57082 L 573.34352,394.43884 z "
+ id="path1947" />
+ <rect
+ style="fill:#317fed;fill-opacity:1;stroke:#060000;stroke-width:2.00000024;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
+ id="rect1949"
+ width="115.66247"
+ height="70.148659"
+ x="596.20831"
+ y="452.59158"
+ rx="6.9961648"
+ ry="5.8193965" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1951"
+ transform="translate(335.9032,253.0819)"><flowRegion
+ id="flowRegion1953"><rect
+ id="rect1955"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591" /></flowRegion><flowPara
+ id="flowPara1957">Divide</flowPara><flowPara
+ id="flowPara1959">Service</flowPara><flowPara
+ id="flowPara1961">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 574.77209,475.15313 L 608.10713,475.15313 L 614.16804,488.28511 L 607.09698,500.40695 L 574.77209,500.40695 L 582.34824,488.28511 L 574.77209,475.15313 z "
+ id="path1963" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1965"
+ transform="translate(161.0221,114.967)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1967"><rect
+ id="rect1969"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1973">add</flowPara><flowPara
+ id="flowPara1977">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 430.65917,357.18186 L 470.64255,357.18186 L 477.91225,370.31384 L 469.43094,382.43568 L 430.65917,382.43568 L 439.74631,370.31384 L 430.65917,357.18186 z "
+ id="path1979" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1981"
+ transform="translate(160.6632,150.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1983"><rect
+ id="rect1985"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1987">subtract</flowPara><flowPara
+ id="flowPara1989">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 431.37346,390.75329 L 471.35684,390.75329 L 478.62654,403.88527 L 470.14523,416.00711 L 431.37346,416.00711 L 440.4606,403.88527 L 431.37346,390.75329 z "
+ id="path1991" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot1993"
+ transform="translate(161.3775,184.2583)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion1995"><rect
+ id="rect1997"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara1999">multiply</flowPara><flowPara
+ id="flowPara2001">Service</flowPara></flowRoot> <path
+ style="fill:#ae62bf;fill-opacity:1;fill-rule:evenodd;stroke:black;stroke-width:0.99999982px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 429.94489,422.18186 L 469.92827,422.18186 L 477.19797,435.31384 L 468.71666,447.43568 L 429.94489,447.43568 L 439.03203,435.31384 L 429.94489,422.18186 z "
+ id="path2003" />
+ <flowRoot
+ xml:space="preserve"
+ id="flowRoot2005"
+ transform="translate(159.9489,215.6868)"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans"><flowRegion
+ id="flowRegion2007"><rect
+ id="rect2009"
+ width="170"
+ height="61.42857"
+ x="281.42856"
+ y="212.66591"
+ style="font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;font-family:Bitstream Vera Sans" /></flowRegion><flowPara
+ id="flowPara2011">divide</flowPara><flowPara
+ id="flowPara2013">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 477.85714,335.52305 L 511.42857,335.52305 L 510.71429,245.52305 L 579.28571,245.52305"
+ id="path2015" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 477.85714,369.80877 L 528.57143,369.80877 L 528.57143,329.80877 L 580,329.80877"
+ id="path2017" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 478.57143,402.66591 L 528.57143,401.95163 L 528.57143,408.3802 L 580,407.66591"
+ id="path2019" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 475.71429,435.52305 L 509.28571,435.52305 L 510,486.95163 L 582.14286,486.23734"
+ id="path2021" />
+ <path
+ style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+ d="M 292.85714,355.52305 L 330,354.80877"
+ id="path2023" />
+ </g>
+</svg>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/pom.xml
new file mode 100644
index 0000000000..590fa6f6ea
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>sample-implementation-java-calculator</artifactId>
+ <name>Apache Tuscany SCA Sample Implementation Java Calculator</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-feature-api</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-feature-core</artifactId>
+ <type>pom</type>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java
new file mode 100644
index 0000000000..188451ebac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java
new file mode 100644
index 0000000000..7ca8fb04b5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java
new file mode 100644
index 0000000000..84c98d7f70
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java
new file mode 100644
index 0000000000..031fa8b912
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java
new file mode 100644
index 0000000000..17fad7de6b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java
new file mode 100644
index 0000000000..30d248208b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java
new file mode 100644
index 0000000000..1323edf55a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java
new file mode 100644
index 0000000000..5290605938
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java
new file mode 100644
index 0000000000..91b803bc9e
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java
new file mode 100644
index 0000000000..bf0d1882b6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java
new file mode 100644
index 0000000000..58cc4a3547
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/main/resources/Calculator.composite
new file mode 100644
index 0000000000..9450558145
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java
new file mode 100644
index 0000000000..461c970373
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.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.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.equinox.launcher.Contribution;
+import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * This shows how to test the Calculator composition.
+ */
+public class CalculatorTestCase {
+
+ private static NodeLauncher launcher;
+ private static Node node;
+ private static String status = "Sample Success";
+
+ public static void main(String[] args) throws Exception {
+ setUpBeforeClass();
+ tearDownAfterClass();
+ }
+
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ launcher = NodeLauncher.newInstance();
+ String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class);
+ node = launcher.createNode("Calculator.composite", new Contribution("test", location));
+
+ try {
+ node.start();
+ } catch (Exception ex) {
+ status = ex.toString();
+ System.out.println(status);
+ }
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ if (node != null) {
+ node.stop();
+ node.destroy();
+ }
+ if (launcher != null) {
+ launcher.destroy();
+ }
+ }
+
+ @Test
+ public void testSample() throws Exception {
+ Assert.assertEquals("Sample Success", status);
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/logging.properties b/tags/java/sca/2.0-M4-RC2/samples/logging.properties
new file mode 100644
index 0000000000..cf452e7812
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/pom.xml
new file mode 100644
index 0000000000..6ada609ce9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <artifactId>tuscany-samples</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Tuscany SCA Samples</name>
+
+ <repositories>
+ <repository>
+ <id>apache.incubator</id>
+ <url>http://people.apache.org/repo/m2-incubating-repository</url>
+ </repository>
+ </repositories>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>calculator</module>
+ <module>calculator-equinox</module>
+ <module>calculator-osgi</module>
+ <module>calculator-rmi-reference</module>
+ <module>calculator-rmi-service</module>
+
+ <module>dosgi-calculator</module>
+ <module>dosgi-calculator-operations</module>
+
+ <module>dosgi-dynamic-calculator</module>
+
+ <module>dosgi-dynamic-calculator-operations</module>
+
+ <module>helloworld-bpel</module>
+
+ <module>implementation-java-calculator</module>
+ <module>binding-ws-calculator</module>
+
+ <module>webapps/helloworld</module>
+ <module>webapps/helloworld-bpel</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-rest</module>
+ <module>webapps/helloworld-wicket</module>
+-->
+ </modules>
+ </profile>
+ </profiles>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/pom.xml
new file mode 100644
index 0000000000..6c80b939e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/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 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>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-bpel</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld BPEL</name>
+
+ <properties>
+ <tuscany.version>2.0-M4</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>3.8.2</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>${artifactId}</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>${jetty.version}</version>
+ </plugin>
+
+ </plugins>
+ </build>
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..c1a50d9be5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel
new file mode 100644
index 0000000000..f1e8895f76
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl
new file mode 100644
index 0000000000..46cf381577
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..3ffe604ef7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..bf01a7b759
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..c52d7b1cb2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/README b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/README
new file mode 100644
index 0000000000..88bbe9adcb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/pom.xml
new file mode 100644
index 0000000000..09dddbd07d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-jms</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample JMS HelloWorld in a WebApp</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-jms-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>activemq-core</artifactId>
+ <version>5.1.0</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>backport-util-concurrent</groupId>
+ <artifactId>backport-util-concurrent</artifactId>
+ <version>3.1</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java
new file mode 100644
index 0000000000..f209f11605
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java
new file mode 100644
index 0000000000..df2a852161
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..c09af51e23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml
new file mode 100644
index 0000000000..7575edfc29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml
new file mode 100644
index 0000000000..a8cd27f6c6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..5c52638661
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..86710435ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..9ae037f2c2
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/pom.xml
new file mode 100644
index 0000000000..32799fbf46
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-js-client</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld Javascript Client</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-client</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..123774b936
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..66cef71a25
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..c59c7a8f6d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..babeb7b203
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/hello.html b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-js-client/src/main/webapp/hello.html
new file mode 100644
index 0000000000..12024cc4d3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/pom.xml
new file mode 100644
index 0000000000..9917a2c880
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-jsf</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-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-myfaces</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java
new file mode 100644
index 0000000000..9c9f541997
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..23925d6c69
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml
new file mode 100644
index 0000000000..99cee9faeb
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..875d6aae9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..fecbd7c79b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp
new file mode 100644
index 0000000000..189c142c99
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp
new file mode 100644
index 0000000000..5ca296e115
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp
new file mode 100644
index 0000000000..89259021c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/pom.xml
new file mode 100644
index 0000000000..22d399f4cd
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-jsp</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld JSP</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a22c095f29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..875d6aae9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..fa1f7ad7b9
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp
new file mode 100644
index 0000000000..ffd01cca73
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/README b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/README
new file mode 100644
index 0000000000..00568d9bb0
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/README
@@ -0,0 +1,37 @@
+Hello World REST Sample
+=======================
+
+Sample Overview
+---------------
+The service 'HelloWorldService' is exposed using the REST binding.
+
+helloworld-jsonrpc-webapp/
+ src/
+ main/
+ java/
+ helloworldjsonrpc/
+ HelloWorldService.java - service interface
+ HelloWorldServiceImpl.java - service implementation
+ ClientTestServiceWebapp.java - Test class; uses java.net.HttpURLConnection to make 'GET', 'PUT', 'POST requests
+ resources/
+ rest.composite - the SCA assembly for this sample
+ webapp
+ META-INF/
+ sca-contribution.xml - specifies the composite to be deployed
+ WEB-INF/
+ web.xml - defines the listener that starts up the
+ Tuscany SCA runtime
+ pom.xml - the Maven build file
+
+Build the sample using Maven.
+A war 'helloworld-rest-webapp.war' will be created in the target directory. Deploy it in your web container.
+You can access the service from the browser by making a simple GET request using the following URL:
+http://<host>:<port>/helloworld-rest-webapp/HelloWorldService/helloworld/getname
+
+Use the test class 'ClientTestServiceWebapp' to test PUT, POST operations.
+
+
+
+
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/pom.xml
new file mode 100644
index 0000000000..ce70092d3d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+ <artifactId>helloworld-rest</artifactId>
+ <packaging>war</packaging>
+ <name>HelloWorld RESTFul Web Application</name>
+
+ <repositories>
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/2/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
+ <id>maven-repository.dev.java.net</id>
+ <name>Java.net Maven 1 Repository (legacy)</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+ </repositories>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node-impl</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-binding-rest-runtime</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.0</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-bundle</artifactId>
+ <version>1.0.3</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java
new file mode 100644
index 0000000000..8b19af7a52
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java
@@ -0,0 +1,29 @@
+package helloworldrest;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+
+/*
+ * To test, simply run the program
+ * Access the service by invoking the getName() method of HelloWorldService
+ */
+
+public class ClientJavaTestService {
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args) {
+ NodeFactory factory = NodeFactory.newInstance();
+ Node node = factory.createNode("rest.composite", ClientJavaTestService.class.getClassLoader()).start();
+ HelloWorldService helloService = node.getService(HelloWorldService.class, "HelloWorldRESTServiceComponent");
+
+ //HelloWorldService helloService = new HelloWorldServiceImpl();
+ System.out.println("### Message from REST service " + helloService.getName());
+
+ node.stop();
+ node.destroy();
+ factory.destroy();
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java
new file mode 100644
index 0000000000..fb83b26315
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java
@@ -0,0 +1,108 @@
+package helloworldrest;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Formatter;
+
+/**
+ *
+ * To test, deploy the application as a webapp.
+ * Then, run this file to access the REST web service by making HTTP GET/POST requests
+ *
+ */
+public class ClientTestServiceWebapp {
+
+ final static String UrlBase = "http://localhost:8080/helloworld-rest-webapp/HelloWorldService";
+
+ final static class HttpResponse {
+ Object content;
+ int code;
+ String message;
+ }
+
+ static HttpResponse makeHttpGetRequest(String method, String url, String contentType) throws Exception {
+ HttpResponse response = new HttpResponse();
+ URL urlAddress = new URL(url);
+ HttpURLConnection huc = (HttpURLConnection)urlAddress.openConnection();
+ huc.setRequestMethod(method);
+ huc.setRequestProperty("Content-type", contentType);
+ huc.connect();
+ InputStreamReader isr = new InputStreamReader(huc.getInputStream());
+
+ BufferedReader in = new BufferedReader(isr);
+ String uline = in.readLine();
+ response.content = uline;
+
+ // huc.disconnect();
+ // System.out.println("#### huc disconnected ###");
+
+ return response;
+ }
+
+ static HttpResponse makeHttpRequest(String method, String url, String contentType, InputStream is) throws Exception {
+ HttpResponse response = new HttpResponse();
+ URL urlAddress = new URL(url);
+ HttpURLConnection huc = (HttpURLConnection)urlAddress.openConnection();
+ huc.setRequestMethod(method);
+ if (null != is) {
+ huc.setDoOutput(true);
+ huc.setRequestProperty("Content-Type", contentType);
+ OutputStream os = huc.getOutputStream();
+ byte[] buf = new byte[1024];
+ int read;
+ while ((read = is.read(buf)) != -1) {
+ os.write(buf, 0, read);
+ }
+ }
+ InputStreamReader isr = new InputStreamReader(huc.getInputStream());
+ BufferedReader in = new BufferedReader(isr);
+ String uline = in.readLine();
+ response.content = uline;
+ return response;
+ }
+
+ static HttpResponse makeHttpGetRequest(String method, String url, String contentType, String content)
+ throws Exception {
+ return makeHttpRequest(method, url, contentType, new ByteArrayInputStream(content.getBytes("UTF-8")));
+ }
+
+ static HttpResponse makeHttpRequest(String method, String url) throws Exception {
+ return makeHttpRequest(method, url, null, (InputStream)null);
+ }
+
+ public static void main(String[] args) {
+ try {
+
+ HttpResponse response;
+
+ System.out.println("Getting the name *BEFORE* setting it:");
+ response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+ System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+
+ System.out.println("Setting the name:");
+ String newText = "Morpheus";
+ InputStream inputStream = new ByteArrayInputStream(newText.getBytes());
+ response = makeHttpRequest("PUT", UrlBase + "/helloworld/setname", "text/plain", inputStream);
+
+ System.out.println("Getting the name *AFTER* setting it:");
+ response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+ System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+
+ System.out.println("POST Operation:");
+ response = makeHttpGetRequest("POST", UrlBase + "/helloworld/postoperation/prateek", "text/plain");
+ //System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+
+ System.out.println("Getting the name *AFTER* the POST operation:");
+ response = makeHttpGetRequest("GET", UrlBase + "/helloworld/getname", "text/plain");
+ System.out.println(new Formatter().format("---- Received String:\n%s", response.content.toString()));
+ } catch (Exception e) {
+ System.out.println("TEST FAILED! :-(");
+ e.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java
new file mode 100644
index 0000000000..fb9d3e2f82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java
@@ -0,0 +1,13 @@
+package helloworldrest;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+@Remotable
+public interface HelloWorldService {
+
+ public void setName(String name);
+
+ public String getName();
+
+ public void postOperationTest(String name);
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java
new file mode 100644
index 0000000000..cacb88b5e3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java
@@ -0,0 +1,44 @@
+package helloworldrest;
+
+import javax.ws.rs.Consumes;
+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 javax.ws.rs.Produces;
+
+import org.oasisopen.sca.annotation.Scope;
+import org.oasisopen.sca.annotation.Service;
+
+@Service(HelloWorldService.class)
+@Scope("Composite")
+@Path("/helloworld")
+public class HelloWorldServiceImpl implements HelloWorldService {
+
+ private String name = new String("original!");
+
+ @Path("/setname")
+ @PUT
+ @Consumes("text/plain")
+ public void setName(String name) {
+ this.name = name;
+
+ }
+
+ //http://<host>:<port>/helloworld-rest-webapp/HelloWorldService/helloworld/getname
+ @Path("/getname")
+ @GET
+ @Produces("text/plain")
+ public String getName() {
+ return this.name;
+ }
+
+ @POST
+ @Path("/postoperation/{name}/")
+ @Consumes("text/plain")
+ public void postOperationTest(@PathParam("name") String name) {
+ this.name = name;
+ }
+
+}
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/resources/rest.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/resources/rest.composite
new file mode 100644
index 0000000000..7f76f5946d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/resources/rest.composite
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="helloworldrest">
+
+ <service name="HelloWorldService" promote="HelloWorldRESTServiceComponent/HelloWorldService">
+ <interface.java interface="helloworldrest.HelloWorldService"/>
+ <tuscany:binding.rest />
+ </service>
+
+ <component name="HelloWorldRESTServiceComponent">
+ <implementation.java class="helloworldrest.HelloWorldServiceImpl"/>
+ </component>
+
+</composite>
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html
new file mode 100644
index 0000000000..745164bf8d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html
@@ -0,0 +1,75 @@
+<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.
+ -->
+ <head>
+ <title>Tuscany JSON-RPC HelloWorld Example</TITLE>
+
+ <script type="text/javascript" src="SCADomain/scaDomain.js"></script>
+
+ <script language="JavaScript">
+
+ function getGreeting() {
+ var name = document.getElementById("name").value;
+ HelloWorldService.getGreetings(name, handleResponse);
+ }
+
+ function handleResponse(result) {
+ document.getElementById('greeting').innerHTML=result;
+ }
+
+ </script>
+
+ <link rel="stylesheet" type="text/css" href="style.css" />
+ </head>
+
+ <body>
+
+ <h2>Tuscany JSON-RPC HelloWorld Sample</h2>
+
+ <table>
+ <tr>
+ <th colspan="2">Non-Dojo Example</th>
+ </tr>
+ <tr>
+ <td colspan="2">
+ This example uses the JavaScript served from
+ <a href="SCADomain/scaDomain.js">SCADomain/scaDomain.js</a>
+ to make JSON-RPC requests to the SCA service 'HelloWorldService'
+ </tr>
+ <tr>
+ <td>Request</td>
+ <td>Response</td>
+ </tr>
+ <tr>
+ <td>
+ <p>
+ Name please: &nbsp;&nbsp;&nbsp;
+ <input type="text" id="name" size="30" value="World" />
+ <input type="button" value="Submit" onclick="getGreeting()" />
+ </p>
+
+ </td>
+ <td>
+ <div id='greeting'>None Yet.</div>
+ </td>
+ </tr>
+ </table>
+
+ </body>
+</html>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..9fc16372b3
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml
@@ -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.
+-->
+
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample">
+ <deployable composite="sample:helloworldrest"/>
+</contribution>
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..3a670696e4
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,35 @@
+<?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>
+
+ <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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/style.css b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/style.css
new file mode 100644
index 0000000000..0f1cea3aaf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/src/main/webapp/style.css
@@ -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.
+ */
+* { font-family: arial; }
+
+table, th, td { border: 2px solid blue; border-collapse: collapse; }
+th { color: white; background-color: blue; }
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/target/classes/rest.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/target/classes/rest.composite
new file mode 100644
index 0000000000..70b83fd986
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-rest/target/classes/rest.composite
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ targetNamespace="http://sample"
+ xmlns:sample="http://sample"
+ name="helloworldrest">
+
+ <service name="HelloWorldService" promote="HelloWorldRESTServiceComponent/HelloWorldService">
+ <interface.java interface="helloworldrest.HelloWorldService"/>
+ <tuscany:binding.rest />
+ </service>
+
+ <component name="HelloWorldRESTServiceComponent">
+ <implementation.java class="helloworldrest.HelloWorldServiceImpl"/>
+ </component>
+
+</composite>
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/pom.xml
new file mode 100644
index 0000000000..e979a251c7
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-servlet</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld Servlet</name>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-implementation-web-runtime</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..2e43e09897
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..9e79276704
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java
new file mode 100644
index 0000000000..bb72c50f6a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..875d6aae9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..a91b3fc96b
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/hello.html b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-servlet/src/main/webapp/hello.html
new file mode 100644
index 0000000000..c4484916aa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/pom.xml
new file mode 100644
index 0000000000..0ae346e2cf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/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-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-stripes</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld using Stripes</name>
+
+ <dependencies>
+
+ <!-- Tuscany dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-stripes</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+
+ <!-- Stripes Framework dependencies -->
+ <dependency>
+ <groupId>net.sourceforge.stripes</groupId>
+ <artifactId>stripes</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>taglibs</groupId>
+ <artifactId>standard</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java
new file mode 100644
index 0000000000..0ab02682ac
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java
new file mode 100644
index 0000000000..0385c92369
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a22c095f29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties
new file mode 100644
index 0000000000..a23399569a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties
@@ -0,0 +1,57 @@
+
+# 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..77fa204a15
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties
@@ -0,0 +1,31 @@
+# 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp
new file mode 100644
index 0000000000..0681c1f2bf
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp
new file mode 100644
index 0000000000..d0fb716b80
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp
new file mode 100644
index 0000000000..f85602fcfa
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..875d6aae9d
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/200903"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..f01584cc2f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/index.html b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-stripes/src/main/webapp/index.html
new file mode 100644
index 0000000000..c79d29e6a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/pom.xml
new file mode 100644
index 0000000000..af11fa2cba
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/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-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld-wicket</artifactId>
+ <packaging>war</packaging>
+ <name>Apache Tuscany SCA Sample Helloworld using Wicket</name>
+
+ <dependencies>
+
+ <!-- Tuscany dependencies -->
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-wicket</artifactId>
+ <version>2.0-M4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Wicket dependencies -->
+ <dependency>
+ <groupId>org.apache.wicket</groupId>
+ <artifactId>wicket</artifactId>
+ <version>1.4-rc2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.14</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..a22c095f29
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html
new file mode 100644
index 0000000000..61eb207e23
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html
@@ -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.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+ <title>Wicket Examples - guice</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+</head>
+<body>
+ <p>
+ This page uses <a href="http://code.google.com/p/google-guice/">Google Guice</a>.
+ There is a service interface called <code>IMyService</code>, with an implementation POJO called <code>MyService</code>.
+ Guice is used to wire the implementation into the <code>Page</code> using an <code>@Inject</code> annotation. You can use this
+ annotation on the fields of any <code>Component</code> subclass.
+ </p>
+ <p>
+ The value of the <code>Label</code> component below will be updated with the return value from one of the service's methods when you click the link.
+ </p>
+ <hr />
+ <blockquote>
+ Value: <b wicket:id="message" id="message">Message goes here</b>
+ <br />
+ To update the label above, <a href="#" wicket:id="link">click here</a>.
+ </blockquote>
+ <hr />
+ <p>
+ The wicket-guice project will take care of proxying the injected beans so that your pages can be serialized safely.
+ To configure your application for Guice injection, see the javadoc for <code>GuiceComponentInjector</code>.
+ </p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java
new file mode 100644
index 0000000000..061f4c58ae
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.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 sample.wicket;
+
+import org.apache.wicket.markup.html.WebPage;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.model.AbstractReadOnlyModel;
+import org.oasisopen.sca.annotation.Reference;
+
+/**
+ * Everybody's favorite example (Hello World), modified to use Guice.
+ *
+ * @author Alastair Maw
+ */
+public class HomePage extends WebPage
+{
+ @Reference
+ IMyService service;
+
+ private String labelValue = "<not yet initialized>";
+
+ /**
+ * Constructor
+ */
+ public HomePage()
+ {
+ add(new Link("link")
+ {
+ /**
+ * @see org.apache.wicket.markup.html.link.Link#onClick()
+ */
+ @Override
+ public void onClick()
+ {
+ labelValue = service.getHelloWorldText();
+ }
+ });
+ add(new Label("message", new AbstractReadOnlyModel<String>()
+ {
+
+ @Override
+ public String getObject()
+ {
+ return labelValue;
+ }
+
+ }));
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java
new file mode 100644
index 0000000000..fdd91b0933
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.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 sample.wicket;
+
+
+/**
+ * Service interface for a simple "Hello World" app.
+ *
+ * @author Alastair Maw
+ */
+public interface IMyService
+{
+ /**
+ * Retrieves the text to say "Hello World".
+ *
+ * @return "Hello World"
+ */
+ public String getHelloWorldText();
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java
new file mode 100644
index 0000000000..e7d864c5e6
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package sample.wicket;
+
+
+/**
+ * Implementation of IService.
+ *
+ * @author Alastair Maw
+ */
+public class MyService implements IMyService
+{
+
+ /**
+ * @see org.apache.wicket.examples.guice.service.IMyService#getHelloWorldText()
+ */
+ public String getHelloWorldText()
+ {
+ return "Hello World";
+ }
+
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java
new file mode 100644
index 0000000000..85f2c00dbc
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.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 sample.wicket;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.tuscany.sca.wicket.TuscanyComponentInjector;;
+
+/**
+ * Application object for your web application. If you want to run this application without deploying, run the Start class.
+ *
+ * @see com.mycompany.Start#main(String[])
+ */
+public class WicketApplication extends WebApplication
+{
+
+ @Override
+ protected void init()
+ {
+ addComponentInstantiationListener(new TuscanyComponentInjector(this));
+ }
+
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class< ? extends Page> getHomePage()
+ {
+ return HomePage.class;
+ }
+} \ No newline at end of file
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties
new file mode 100644
index 0000000000..1e24577860
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/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.
+#
+
+log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n
+
+log4j.rootLogger=INFO,Stdout
+
+log4j.logger.org.apache.wicket=INFO
+log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO
+log4j.logger.org.apache.wicket.version=INFO
+log4j.logger.org.apache.wicket.RequestCycle=INFO
+
+
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..a52d6b6cbe
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/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/200712"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0"
+ 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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..3783b7bf82
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/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-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 Wicket Sample</display-name>
+
+ <listener>
+ <listener-class>org.apache.tuscany.sca.host.webapp.TuscanyContextListener</listener-class>
+ </listener>
+
+ <!--
+ There are three means to configure Wickets configuration mode and they are
+ tested in the order given.
+ 1) A system property: -Dwicket.configuration
+ 2) servlet specific <init-param>
+ 3) context specific <context-param>
+ The value might be either "development" (reloading when templates change)
+ or "deployment". If no configuration is found, "development" is the default.
+ -->
+
+ <filter>
+ <filter-name>wicket.tuscany</filter-name>
+ <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+ <param-value>sample.wicket.WicketApplication</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>wicket.tuscany</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+</web-app>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/pom.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/pom.xml
new file mode 100644
index 0000000000..618c941e5a
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/pom.xml
@@ -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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>2.0-M4</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>helloworld</artifactId>
+ <name>Apache Tuscany SCA Sample Helloworld</name>
+ <packaging>war</packaging>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>2.0-M4</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-M4</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.18</version>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java
new file mode 100644
index 0000000000..53ff7a5ca1
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java
new file mode 100644
index 0000000000..8d220029a5
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/java/sample/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 sample;
+
+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/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite
new file mode 100644
index 0000000000..045aa4674f
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.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"
+ xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.1"
+ targetNamespace="http://samples"
+ name="Helloworld">
+
+ <component name="HelloworldComponent">
+ <implementation.java class="sample.HelloworldServiceImpl"/>
+ </component>
+
+</composite>
diff --git a/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000000..d7b237641c
--- /dev/null
+++ b/tags/java/sca/2.0-M4-RC2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.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.
+-->
+<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>
+
+ <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>