From 613b275ffa5d7ae0c41b625db231c187b8a136ef Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 28 Oct 2009 09:54:25 +0000 Subject: Create 2.0 M4 release branch git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@830484 13f79535-47bb-0310-9956-ffa450edef68 --- branches/sca-java-2.0-M4/BUILDING | 44 + branches/sca-java-2.0-M4/CHANGES | 69 + branches/sca-java-2.0-M4/LICENSE | 485 ++++++ branches/sca-java-2.0-M4/NOTICE | 59 + branches/sca-java-2.0-M4/README | 19 + branches/sca-java-2.0-M4/RELEASE_NOTES | 73 + .../contribution-jar/META-INF/MANIFEST.MF | 11 + .../archetypes/contribution-jar/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 36 + .../main/resources/META-INF/maven/archetype.xml | 30 + .../src/main/resources/archetype-resources/pom.xml | 110 ++ .../src/main/java/HelloworldImpl.java | 36 + .../src/main/java/HelloworldService.java | 28 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/helloworld.composite | 29 + .../archetypes/contribution-zip-discriptor/pom.xml | 33 + .../assemblies/tuscany-zip-contribution.xml | 40 + .../contribution-zip/META-INF/MANIFEST.MF | 11 + .../archetypes/contribution-zip/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 36 + .../main/resources/META-INF/maven/archetype.xml | 30 + .../src/main/resources/archetype-resources/pom.xml | 153 ++ .../archetype-resources/src/main/java/AddImpl.java | 38 + .../src/main/java/AddService.java | 25 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/add.composite | 29 + branches/sca-java-2.0-M4/archetypes/pom.xml | 51 + .../quickstart-bpel/META-INF/MANIFEST.MF | 11 + .../archetypes/quickstart-bpel/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 43 + .../main/resources/META-INF/maven/archetype.xml | 33 + .../src/main/resources/archetype-resources/pom.xml | 182 +++ .../src/main/java/HelloworldService.java | 28 + .../src/main/resources/helloworld.bpel | 66 + .../src/main/resources/helloworld.wsdl | 82 + .../src/main/webapp/WEB-INF/web.composite | 37 + .../src/main/webapp/WEB-INF/web.xml | 41 + .../archetype-resources/src/main/webapp/hello.jsp | 36 + .../archetypes/quickstart-jsf/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 44 + .../main/resources/META-INF/maven/archetype.xml | 38 + .../src/main/resources/archetype-resources/pom.xml | 154 ++ .../main/java/myfaces/HelloWorldController.java | 64 + .../src/main/java/sca/HelloworldService.java | 28 + .../src/main/java/sca/HelloworldServiceImpl.java | 30 + .../src/main/webapp/WEB-INF/faces-config.xml | 53 + .../src/main/webapp/WEB-INF/web.composite | 35 + .../src/main/webapp/WEB-INF/web.xml | 230 +++ .../src/main/webapp/helloWorld.jsp | 37 + .../archetype-resources/src/main/webapp/index.jsp | 22 + .../archetype-resources/src/main/webapp/page2.jsp | 35 + .../quickstart-jsonp/META-INF/MANIFEST.MF | 11 + .../archetypes/quickstart-jsonp/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 42 + .../main/resources/META-INF/maven/archetype.xml | 31 + .../src/main/resources/archetype-resources/pom.xml | 154 ++ .../src/main/java/HelloworldImpl.java | 27 + .../src/main/java/HelloworldService.java | 28 + .../src/main/webapp/WEB-INF/web.composite | 32 + .../src/main/webapp/WEB-INF/web.xml | 43 + .../archetype-resources/src/main/webapp/hello.jsp | 36 + .../quickstart-stripes/META-INF/MANIFEST.MF | 11 + .../archetypes/quickstart-stripes/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 44 + .../main/resources/META-INF/maven/archetype.xml | 38 + .../src/main/resources/archetype-resources/pom.xml | 124 ++ .../src/main/java/sca/HelloworldService.java | 28 + .../src/main/java/sca/HelloworldServiceImpl.java | 31 + .../main/java/stripes/action/BaseActionBean.java | 36 + .../main/java/stripes/action/HomeActionBean.java | 48 + .../src/main/resources/StripesResources.properties | 77 + .../src/main/resources/log4j.properties | 51 + .../src/main/webapp/WEB-INF/jsp/home.jsp | 29 + .../src/main/webapp/WEB-INF/jsp/layout.jsp | 42 + .../src/main/webapp/WEB-INF/jsp/taglibs.jsp | 32 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../src/main/webapp/WEB-INF/web.xml | 68 + .../archetype-resources/src/main/webapp/index.html | 27 + .../archetypes/quickstart/META-INF/MANIFEST.MF | 11 + .../sca-java-2.0-M4/archetypes/quickstart/pom.xml | 50 + .../META-INF/maven/archetype-metadata.xml | 42 + .../main/resources/META-INF/maven/archetype.xml | 31 + .../src/main/resources/archetype-resources/pom.xml | 143 ++ .../src/main/java/HelloworldImpl.java | 27 + .../src/main/java/HelloworldService.java | 25 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../src/main/webapp/WEB-INF/web.xml | 43 + .../archetype-resources/src/main/webapp/hello.jsp | 36 + .../distribution/all/manifests/axiom-api-1.2.7.MF | 48 + .../all/manifests/woden-impl-dom-1.0M8.MF | 229 +++ branches/sca-java-2.0-M4/distribution/all/pom.xml | 120 ++ .../distribution/all/src/main/assembly/bin.xml | 36 + .../distribution/all/src/main/assembly/src.xml | 45 + .../all/src/main/components/bin-common.xml | 43 + .../all/src/main/components/bin-launcher.xml | 41 + .../all/src/main/components/bin-modules.xml | 33 + .../all/src/main/components/bin-samples.xml | 80 + .../distribution/all/src/main/release/bin/INSTALL | 24 + .../distribution/all/src/main/release/bin/LICENSE | 1672 ++++++++++++++++++++ .../distribution/all/src/main/release/bin/NOTICE | 85 + .../all/src/main/release/launcher/README | 42 + .../all/src/main/release/launcher/default.config | 22 + .../all/src/main/release/launcher/osgi.config | 21 + .../all/src/main/release/launcher/tuscany.bat | 83 + .../all/src/main/release/launcher/tuscany.sh | 54 + .../all/src/main/release/launcher/unmanaged.config | 21 + branches/sca-java-2.0-M4/distribution/pom.xml | 38 + .../sca-java-2.0-M4/distribution/tomcat/README.txt | 8 + .../sca-java-2.0-M4/distribution/tomcat/pom.xml | 40 + .../tomcat/testing/download-tomcat/pom.xml | 63 + .../testing/helloworld-client-webapp/pom.xml | 47 + .../src/main/java/testing/HelloworldService.java | 27 + .../src/main/webapp/WEB-INF/web.composite | 30 + .../src/main/webapp/WEB-INF/web.xml | 31 + .../src/main/webapp/hello.jsp | 36 + .../helloworld-service-contribution/pom.xml | 45 + .../src/main/java/testing/HelloworldImpl.java | 36 + .../src/main/java/testing/HelloworldService.java | 25 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/helloworld.composite | 28 + .../tomcat/testing/legal-checks/pom.xml | 36 + .../src/test/java/itest/JarsInLICENSETestCase.java | 147 ++ .../distribution/tomcat/testing/pom.xml | 39 + .../distribution/tomcat/tomcat-hook/LICENSE | 205 +++ .../tomcat/tomcat-hook/META-INF/MANIFEST.MF | 24 + .../distribution/tomcat/tomcat-hook/NOTICE | 7 + .../distribution/tomcat/tomcat-hook/pom.xml | 70 + .../sca/tomcat/TuscanyAnnotationsProcessor.java | 85 + .../sca/tomcat/TuscanyLifecycleListener.java | 170 ++ .../tuscany/sca/tomcat/TuscanyStandardContext.java | 185 +++ .../tomcat/tomcat-servlet/META-INF/MANIFEST.MF | 11 + .../distribution/tomcat/tomcat-servlet/pom.xml | 63 + .../tuscany/sca/tomcat/foo/TuscanyTomcatNode.java | 74 + .../java/org/apache/tuscany/sca/war/Installer.java | 318 ++++ .../apache/tuscany/sca/war/InstallerServlet.java | 70 + .../distribution/tomcat/tomcat-war/pom.xml | 101 ++ .../tomcat/tomcat-war/src/main/assembly/war.xml | 95 ++ .../tomcat/tomcat-war/src/main/webapp/LICENSE | 1117 +++++++++++++ .../tomcat/tomcat-war/src/main/webapp/NOTICE | 79 + .../tomcat-war/src/main/webapp/WEB-INF/web.xml | 40 + .../tomcat-war/src/main/webapp/installer.jsp | 74 + branches/sca-java-2.0-M4/features/all/pom.xml | 98 ++ branches/sca-java-2.0-M4/features/api/pom.xml | 58 + branches/sca-java-2.0-M4/features/core/pom.xml | 230 +++ branches/sca-java-2.0-M4/features/ejava/pom.xml | 133 ++ branches/sca-java-2.0-M4/features/pom.xml | 48 + branches/sca-java-2.0-M4/features/process/pom.xml | 57 + branches/sca-java-2.0-M4/features/web20/pom.xml | 81 + branches/sca-java-2.0-M4/features/webapp/pom.xml | 96 ++ .../sca-java-2.0-M4/features/webservice/pom.xml | 122 ++ .../itest/bpel/helloworld-reference/pom.xml | 288 ++++ .../src/test/java/greetings/GreetingsService.java | 31 + .../test/java/greetings/GreetingsServiceImpl.java | 33 + .../src/test/java/greetings/GreetingsTestCase.java | 65 + .../test/java/helloworld/HelloWorldService.java | 29 + .../java/helloworld/HelloWorldServiceImpl.java | 47 + .../test/java/helloworld/HelloWorldTestCase.java | 64 + .../test/resources/greetings/greetings.composite | 32 + .../src/test/resources/greetings/greetings.wsdl | 87 + .../src/test/resources/helloworld/helloworld.bpel | 84 + .../test/resources/helloworld/helloworld.composite | 36 + .../src/test/resources/helloworld/helloworld.wsdl | 94 ++ .../src/test/resources/log4j.properties | 36 + .../itest/bpel/helloworld-ws/pom.xml | 178 +++ .../src/test/java/helloworld/HelloWorld.java | 45 + .../test/java/helloworld/HelloWorldTestCase.java | 71 + .../src/test/resources/helloworld/helloworld.bpel | 66 + .../test/resources/helloworld/helloworld.composite | 32 + .../src/test/resources/helloworld/helloworld.wsdl | 82 + .../src/test/resources/log4j.properties | 36 + .../sca-java-2.0-M4/itest/bpel/helloworld/pom.xml | 270 ++++ .../src/test/java/helloworld/HelloWorld.java | 45 + .../test/java/helloworld/HelloWorldTestCase.java | 73 + .../src/test/resources/helloworld/helloworld.bpel | 78 + .../test/resources/helloworld/helloworld.composite | 36 + .../src/test/resources/helloworld/helloworld.wsdl | 94 ++ .../helloworld/src/test/resources/log4j.properties | 36 + branches/sca-java-2.0-M4/itest/bpel/pom.xml | 39 + branches/sca-java-2.0-M4/itest/builder/pom.xml | 119 ++ .../tuscany/sca/itest/builder/ComponentDImpl.java | 43 + .../ComponentDReferenceMultiplicityImpl.java | 48 + .../tuscany/sca/itest/builder/ComponentEImpl.java | 36 + .../tuscany/sca/itest/builder/ComponentFImpl.java | 36 + .../apache/tuscany/sca/itest/builder/Service3.java | 34 + .../tuscany/sca/itest/builder/Service3a.java | 34 + .../scenario1/META-INF/sca-contribution.xml | 23 + .../main/resources/scenario1/scenario1.composite | 45 + .../main/resources/scenario1/scenario1a.composite | 47 + .../scenario10/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario10/scenario10.composite | 62 + .../resources/scenario10/scenario10a.composite | 61 + .../src/main/resources/scenario10/service3.wsdl | 63 + .../scenario11/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario11/scenario11.composite | 59 + .../resources/scenario11/scenario11a.composite | 64 + .../src/main/resources/scenario11/service3.wsdl | 63 + .../scenario12/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario12/scenario12.composite | 58 + .../resources/scenario12/scenario12a.composite | 64 + .../scenario13/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario13/scenario13.composite | 58 + .../resources/scenario13/scenario13a.composite | 64 + .../scenario2/META-INF/sca-contribution.xml | 23 + .../main/resources/scenario2/scenario2.composite | 45 + .../main/resources/scenario2/scenario2a.composite | 47 + .../scenario3/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario3/scenario3.composite | 44 + .../main/resources/scenario3/scenario3a.composite | 48 + .../scenario4/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario4/scenario4.composite | 44 + .../main/resources/scenario4/scenario4a.composite | 48 + .../scenario5/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario5/scenario5.composite | 46 + .../main/resources/scenario5/scenario5a.composite | 47 + .../src/main/resources/scenario5/scenarios.wsdl | 63 + .../scenario6/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario6/scenario6.composite | 47 + .../main/resources/scenario6/scenario6a.composite | 47 + .../src/main/resources/scenario6/scenarios.wsdl | 63 + .../scenario7/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario7/scenario7.composite | 45 + .../main/resources/scenario7/scenario7a.composite | 49 + .../src/main/resources/scenario7/scenarios.wsdl | 63 + .../scenario8/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario8/scenario8.composite | 44 + .../main/resources/scenario8/scenario8a.composite | 50 + .../src/main/resources/scenario8/scenarios.wsdl | 63 + .../scenario9/META-INF/sca-contribution.xml | 24 + .../main/resources/scenario9/scenario9.composite | 60 + .../main/resources/scenario9/scenario9a.composite | 61 + .../tuscany/sca/itest/builder/BuilderTestCase.java | 814 ++++++++++ .../sca/itest/builder/CustomCompositeBuilder.java | 99 ++ .../tuscany/sca/itest/builder/TestUtils.java | 319 ++++ .../sca-java-2.0-M4/itest/callback-api/pom.xml | 58 + .../tuscany/sca/test/CallBackApiCallBack.java | 38 + .../apache/tuscany/sca/test/CallBackApiClient.java | 30 + .../tuscany/sca/test/CallBackApiClientImpl.java | 201 +++ .../tuscany/sca/test/CallBackApiService.java | 50 + .../tuscany/sca/test/CallBackApiServiceImpl.java | 113 ++ .../src/main/resources/CallBackApiTest.composite | 33 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../tuscany/sca/test/CallBackApiTestCase.java | 70 + .../itest/callback-basic-ws/pom.xml | 78 + .../tuscany/sca/test/CallBackBasicCallBack.java | 33 + .../tuscany/sca/test/CallBackBasicClient.java | 28 + .../tuscany/sca/test/CallBackBasicClientImpl.java | 129 ++ .../tuscany/sca/test/CallBackBasicService.java | 37 + .../tuscany/sca/test/CallBackBasicServiceImpl.java | 56 + .../src/main/resources/CallBackBasicTest.composite | 40 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../tuscany/sca/test/CallBackBasicTestCase.java | 56 + .../sca-java-2.0-M4/itest/callback-basic/pom.xml | 58 + .../tuscany/sca/test/CallBackBasicCallBack.java | 33 + .../tuscany/sca/test/CallBackBasicClient.java | 28 + .../tuscany/sca/test/CallBackBasicClientImpl.java | 129 ++ .../tuscany/sca/test/CallBackBasicService.java | 37 + .../tuscany/sca/test/CallBackBasicServiceImpl.java | 56 + .../src/main/resources/CallBackBasicTest.composite | 33 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../tuscany/sca/test/CallBackBasicTestCase.java | 56 + .../itest/callback-complex-type/pom.xml | 53 + .../tuscany/sca/test/CallBackCTypeCallBack.java | 33 + .../tuscany/sca/test/CallBackCTypeClient.java | 28 + .../tuscany/sca/test/CallBackCTypeClientImpl.java | 138 ++ .../tuscany/sca/test/CallBackCTypeService.java | 37 + .../tuscany/sca/test/CallBackCTypeServiceImpl.java | 59 + .../main/resources/CallBackCTypeClient.composite | 33 + .../test/CallBackCTypeServiceImpl.componentType | 28 + .../tuscany/sca/test/CallBackCTypeTestCase.java | 54 + .../itest/callback-multiple-wires/pom.xml | 53 + .../apache/tuscany/sca/test/callback/MyClient.java | 27 + .../tuscany/sca/test/callback/MyClientImpl1.java | 49 + .../tuscany/sca/test/callback/MyClientImpl2.java | 49 + .../tuscany/sca/test/callback/MyService.java | 32 + .../sca/test/callback/MyServiceCallback.java | 27 + .../tuscany/sca/test/callback/MyServiceImpl.java | 45 + .../main/resources/CallbackMultiWireTest.composite | 38 + .../test/callback/CallbackMultiWireTestCase.java | 64 + .../itest/callback-separatethread/pom.xml | 53 + .../sca/itest/CallBackSeparateThreadClient.java | 34 + .../itest/CallBackSeparateThreadClientImpl.java | 186 +++ .../tuscany/sca/itest/EventProcessorCallBack.java | 37 + .../tuscany/sca/itest/EventProcessorService.java | 45 + .../sca/itest/EventProcessorServiceImpl.java | 195 +++ .../resources/CallBackSeparateThreadTest.composite | 31 + .../sca/itest/CallBackSeparateThreadTestCase.java | 73 + .../sca-java-2.0-M4/itest/component-type/pom.xml | 53 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 30 + .../src/main/java/calculator/CalculatorClient.java | 49 + .../main/java/calculator/CalculatorService.java | 34 + .../java/calculator/CalculatorServiceImpl.java | 63 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 30 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 30 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../src/main/resources/Calculator.composite | 49 + .../calculator/AddServiceImpl.componentType | 27 + .../calculator/CalculatorServiceImpl.componentType | 43 + .../calculator/DivideServiceImpl.componentType | 27 + .../calculator/MultiplyServiceImpl.componentType | 27 + .../calculator/SubtractServiceImpl.componentType | 27 + .../test/java/calculator/CalculatorTestCase.java | 60 + .../itest/contribution-folder/pom.xml | 46 + .../test/java/calculator/CalculatorService.java | 31 + .../test/java/test/ContributionFolderTestCase.java | 55 + .../repository/folderWithJars/Calculator.composite | 49 + .../folderWithJars/META-INF/sca-contribution.xml | 23 + .../repository/folderWithJars/service.jar | Bin 0 -> 2380 bytes .../repository/folderWithJars/serviceImpl.jar | Bin 0 -> 4655 bytes .../test/resources/repository3/contribution.zip | Bin 0 -> 5478 bytes .../export-composite/pom.xml | 67 + .../src/main/java/hello/Hello.java | 30 + .../src/main/java/hello/HelloImpl.java | 33 + .../main/resources/META-INF/sca-contribution.xml | 25 + .../src/main/resources/hello.composite | 31 + .../sca/test/contribution/HelloTestCase.java | 91 ++ .../contribution-import-export/export-java/pom.xml | 67 + .../main/java/helloworld/HelloWorldService.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../helloworld/HelloWorldImpl.componentType | 30 + .../export-resource/pom.xml | 31 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/ufservices/store.html | 27 + .../contribution-import-export/export-wsdl/pom.xml | 31 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../export-wsdl/src/main/resources/helloworld.wsdl | 76 + .../export-wsdl/src/main/resources/helloworld.xsd | 35 + .../import-composite/pom.xml | 73 + .../src/main/java/helloworld/HelloWorldImpl.java | 38 + .../src/main/java/helloworld/HelloWorldServer.java | 46 + .../main/java/helloworld/HelloWorldService.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 27 + .../src/main/resources/helloworld.wsdl | 76 + .../src/main/resources/helloworld.xsd | 35 + .../src/main/resources/helloworldws.composite | 39 + .../contribution/HelloWorldServerTestCase.java | 126 ++ .../contribution-import-export/import-java/pom.xml | 73 + .../src/main/java/helloworld/HelloWorldImpl.java | 33 + .../main/resources/META-INF/sca-contribution.xml | 25 + .../src/main/resources/helloworldws.composite | 29 + .../contribution/HelloWorldServerTestCase.java | 127 ++ .../import-resource/pom.xml | 102 ++ .../main/resources/META-INF/sca-contribution.xml | 25 + .../src/main/resources/store.composite | 33 + .../sca/test/contribution/StoreTestCase.java | 129 ++ .../contribution-import-export/import-wsdl/pom.xml | 73 + .../src/main/java/helloworld/HelloWorldImpl.java | 33 + .../src/main/java/helloworld/HelloWorldServer.java | 46 + .../main/java/helloworld/HelloWorldService.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 25 + .../src/main/resources/helloworldws.composite | 33 + .../contribution/HelloWorldServerTestCase.java | 137 ++ .../itest/contribution-import-export/pom.xml | 56 + .../sca-java-2.0-M4/itest/contribution-zip/pom.xml | 45 + .../test/java/calculator/CalculatorService.java | 31 + .../contribution/zip/ContributionZIPTestCase.java | 56 + .../src/test/resources/repository/contribution.zip | Bin 0 -> 6395 bytes .../itest/distribution/bin-distro-unzip/build.xml | 24 + .../itest/distribution/bin-distro-unzip/pom.xml | 138 ++ .../distribution/binding-ws-calculator/build.xml | 40 + .../distribution/binding-ws-calculator/pom.xml | 82 + .../itest/distribution/calculator-rmi/build.xml | 51 + .../itest/distribution/calculator-rmi/pom.xml | 81 + .../implementation-java-calculator/build.xml | 40 + .../implementation-java-calculator/pom.xml | 82 + .../itest/distribution/legal-checks/pom.xml | 42 + .../src/test/java/itest/JarsInLICENSETestCase.java | 162 ++ .../sca-java-2.0-M4/itest/distribution/pom.xml | 49 + .../distribution/webapp-helloworld-bpel/pom.xml | 124 ++ .../src/test/java/itest/HelloworldTestCase.java | 50 + .../distribution/webapp-helloworld-jms/pom.xml | 216 +++ .../src/test/java/itest/HelloworldTestCase.java | 51 + .../webapp-helloworld-js-client/pom.xml | 188 +++ .../src/test/java/itest/HelloworldTestCase.java | 75 + .../distribution/webapp-helloworld-jsf/pom.xml | 130 ++ .../test/java/itest/HelloworldTestCaseFIXME.java | 71 + .../distribution/webapp-helloworld-jsp/pom.xml | 188 +++ .../src/test/java/itest/HelloworldTestCase.java | 50 + .../distribution/webapp-helloworld-stripes/pom.xml | 124 ++ .../src/test/java/itest/HelloworldTestCase.java | 53 + .../itest/distribution/webapp-helloworld/pom.xml | 121 ++ branches/sca-java-2.0-M4/itest/endpoints/pom.xml | 68 + .../src/test/java/helloworld/HelloWorldImpl.java | 28 + .../test/java/helloworld/HelloWorldService.java | 28 + .../src/test/java/test/EndpointsTestCase.java | 110 ++ .../test/java/test/NestedEndpointsTestCase.java | 110 ++ .../itest/endpoints/src/test/java/test/Utils.java | 70 + .../src/test/resources/helloworld.composite | 116 ++ .../endpoints/src/test/resources/nested.composite | 30 + branches/sca-java-2.0-M4/itest/exceptions/pom.xml | 53 + .../tuscany/sca/test/exceptions/Checked.java | 57 + .../sca/test/exceptions/ExceptionHandler.java | 32 + .../test/exceptions/ExceptionRemoteThrower.java | 30 + .../sca/test/exceptions/ExceptionThrower.java | 37 + .../tuscany/sca/test/exceptions/UnChecked.java | 57 + .../test/exceptions/impl/ExceptionHandlerImpl.java | 115 ++ .../impl/ExceptionRemoteThrowerImpl.java | 44 + .../test/exceptions/impl/ExceptionThrowerImpl.java | 45 + .../impl/RemoteExceptionHandlerImpl.java | 116 ++ .../src/main/resources/ExceptionTest.composite | 41 + .../sca/test/exceptions/ExceptionsTestCase.java | 85 + .../itest/implementation-spring/pom.xml | 80 + .../java/bigbank/stockquote/StockQuoteImpl.java | 38 + .../java/bigbank/stockquote/StockQuoteService.java | 30 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 + .../main/java/calculator/CalculatorService.java | 37 + .../java/calculator/CalculatorServiceImpl.java | 79 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 + .../security/CalculatorCallbackHandler.java | 50 + .../java/calculator/security/JaasLoginModule.java | 178 +++ .../java/calculator/security/UserPrincipal.java | 66 + .../access/SCAApplicationContextProvider.java | 37 + .../src/main/java/helloworld/HelloWorld.java | 35 + .../src/main/java/helloworld/HelloWorldImpl.java | 38 + .../src/main/java/helloworld/HelloWorldProxy.java | 42 + .../src/main/java/mock/TestBean.java | 31 + .../src/main/java/mock/TestBeanImpl.java | 42 + .../src/main/java/mock/TestHelloWorldBean.java | 39 + .../src/main/java/mock/TestReference.java | 27 + .../src/main/java/mock/TestReferenceBean.java | 57 + .../src/main/java/mock/TestSCAPropertyBean.java | 55 + .../spring/annotations/CalculatorServiceImpl.java | 131 ++ .../context/access/CalculatorService-context.xml | 45 + .../context/access/ContextAccess.composite | 49 + .../context/imports/ContextImports.composite | 49 + .../META-INF/spring/CalculatorService-context.xml | 39 + .../META-INF/spring/SpringImport-context.xml | 29 + .../context/multiple/MultipleContext.composite | 30 + .../multiple/springapp/META-INF/MANIFEST.MF | 3 + .../META-INF/spring/SpringHelloWorld-context.xml | 31 + .../META-INF/spring/StockQuoteService-context.xml | 36 + .../springapp/META-INF/spring/beanRefContext.xml | 34 + .../implementation/policies/CalculatorJass.config | 3 + .../policies/CalculatorLogMessages.properties | 18 + .../policies/ImplementationPolicies.composite | 58 + .../META-INF/spring/CalculatorService-context.xml | 39 + .../implementation/policies/definitions.xml | 40 + .../location/folder/SpringFolderLocation.composite | 40 + .../location/folder/springapp/META-INF/MANIFEST.MF | 3 + .../META-INF/spring/SpringSCAProperty-context.xml | 34 + .../location/jar/SpringJarLocation.composite | 40 + .../main/resources/location/jar/spring-context.jar | Bin 0 -> 1454 bytes .../spring/SpringDelegationHelloWorld-context.xml | 39 + .../META-INF/spring/SpringHelloWorld-context.xml | 31 + .../spring/SpringDelegationHelloWorld.composite | 33 + .../sca/itest/spring/SpringHelloWorld.composite | 33 + .../spring/SpringExplicitReference-context.xml | 33 + .../spring/SpringImplicitReference-context.xml | 34 + .../references/SpringExplicitReference.composite | 33 + .../references/SpringImplicitReference.composite | 40 + .../spring/SpringExplicitService-context.xml | 39 + .../spring/SpringImplicitService-context.xml | 31 + .../sca/services/SpringExplicitService.composite | 34 + .../sca/services/SpringImplicitService.composite | 33 + .../spring/annotations/Calculator.composite | 60 + .../annotations/CalculatorService-context.xml | 41 + .../test/java/context/access/CalculatorClient.java | 60 + .../java/context/access/ContextAccessTestCase.java | 32 + .../java/context/imports/CalculatorClient.java | 53 + .../context/imports/ContextImportsTestCase.java | 32 + .../context/multiple/MultipleContextTestCase.java | 32 + .../java/context/multiple/StockQuoteServer.java | 54 + .../implementation/policies/CalculatorClient.java | 76 + .../policies/ImplementationPoliciesTestCase.java | 32 + .../folder/SpringFolderLocationTestCase.java | 45 + .../location/jar/SpringJarLocationTestCase.java | 45 + .../itest/spring/AbstractHelloWorldTestCase.java | 44 + .../sca/itest/spring/AbstractSCATestCase.java | 60 + .../tuscany/sca/itest/spring/HelloWorld.java | 34 + .../tuscany/sca/itest/spring/HelloWorldProxy.java | 41 + .../spring/SpringDelegationHelloWorldTestCase.java | 35 + .../sca/itest/spring/SpringHelloWorldTestCase.java | 36 + .../sca/itest/spring/TestHelloWorldBean.java | 36 + .../itest/spring/TestHelloWorldDelegatorBean.java | 40 + .../SpringExplicitReferenceTestCase.java | 45 + .../SpringImplicitReferenceTestCase.java | 48 + .../services/SpringExplicitServiceTestCase.java | 40 + .../services/SpringImplicitServiceTestCase.java | 38 + .../java/spring/annotations/CalculatorClient.java | 55 + .../annotations/SpringAnnotationsTestCase.java | 32 + branches/sca-java-2.0-M4/itest/interfaces/pom.xml | 53 + .../itest/interfaces/LocalCallbackInterface.java | 30 + .../sca/itest/interfaces/LocalClientComponent.java | 47 + .../itest/interfaces/LocalClientComponentImpl.java | 83 + .../itest/interfaces/LocalServiceComponent.java | 37 + .../interfaces/LocalServiceComponentImpl.java | 49 + .../sca/itest/interfaces/ParameterObject.java | 48 + .../itest/interfaces/RemoteCallbackInterface.java | 33 + .../itest/interfaces/RemoteClientComponent.java | 64 + .../interfaces/RemoteClientComponentImpl.java | 81 + .../itest/interfaces/RemoteServiceComponent.java | 38 + .../interfaces/RemoteServiceComponentImpl.java | 54 + .../src/main/resources/InterfacesTest.composite | 40 + .../resources/InvalidRemoteAttribute.composite | 28 + .../sca/itest/interfaces/InterfacesTestCase.java | 133 ++ .../interfaces/InvalidRemoteAttributeTestCase.java | 49 + .../itest/jaxws-asyncclient/pom.xml | 53 + .../src/main/java/stock/StockQuote.java | 36 + .../src/main/java/stock/StockQuoteClient.java | 69 + .../src/main/java/stock/StockQuoteImpl.java | 34 + .../src/main/java/stock/StockQuoteRef.java | 39 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/StockQuote.composite | 33 + .../src/test/java/itest/AsyncServiceTestCase.java | 67 + branches/sca-java-2.0-M4/itest/jaxws/pom.xml | 53 + .../src/test/java/stock/AsyncServiceTestCase.java | 42 + .../jaxws/src/test/java/stock/StockQuote.java | 45 + .../jaxws/src/test/java/stock/StockQuoteImpl.java | 46 + .../jaxws/src/test/resources/StockQuote.composite | 31 + .../itest/jms/DynamicReplyQ/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/dynamic/client.composite | 34 + .../src/main/resources/jndi.properties | 39 + .../src/main/resources/simple/service.composite | 37 + .../sca/binding/jms/DynamicReplyQTestCase.java | 53 + branches/sca-java-2.0-M4/itest/jms/args/pom.xml | 70 + .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../apache/tuscany/sca/binding/jms/MyService.java | 29 + .../tuscany/sca/binding/jms/ServiceImpl.java | 38 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../jms/args/src/main/resources/jndi.properties | 38 + .../main/resources/selectors/selectors.composite | 38 + .../tuscany/sca/binding/jms/ArgsTestCase.java | 62 + .../sca-java-2.0-M4/itest/jms/callbacks/pom.xml | 73 + .../apache/tuscany/sca/binding/jms/JMSClient.java | 28 + .../tuscany/sca/binding/jms/JMSClientImpl.java | 50 + .../apache/tuscany/sca/binding/jms/JMSService.java | 34 + .../sca/binding/jms/JMSServiceCallback.java | 32 + .../tuscany/sca/binding/jms/JMSServiceImpl.java | 47 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../callbacks/src/main/resources/jndi.properties | 40 + .../src/main/resources/simple/client.composite | 44 + .../src/main/resources/simple/tempq.composite | 50 + .../tuscany/sca/binding/jms/CallbackTestCase.java | 61 + .../sca/binding/jms/TempCallbackQTestCase.java | 64 + .../sca-java-2.0-M4/itest/jms/defaults/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/defaults/client.composite | 31 + .../src/main/resources/defaults/service.composite | 31 + .../defaults/src/main/resources/jndi.properties | 39 + .../tuscany/sca/binding/jms/DefaultsTestCase.java | 54 + .../sca-java-2.0-M4/itest/jms/definitions/pom.xml | 73 + .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../definitions/src/main/resources/definitions.xml | 28 + .../resources/definitions/definitions.composite | 39 + .../definitions/src/main/resources/jndi.properties | 38 + .../sca/binding/jms/DefinitionsTestCase.java | 62 + .../sca-java-2.0-M4/itest/jms/exceptions/pom.xml | 90 ++ .../tuscany/sca/binding/jms/CheckedExcpetion.java | 28 + .../sca/binding/jms/CheckedExcpetion2Args.java | 28 + .../sca/binding/jms/CheckedExcpetionChained.java | 28 + .../sca/binding/jms/CheckedExcpetionNoArgs.java | 28 + .../tuscany/sca/binding/jms/ExceptionService.java | 33 + .../sca/binding/jms/ExceptionServiceImpl.java | 44 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/exceptions/service.composite | 44 + .../exceptions/src/main/resources/jndi.properties | 40 + .../sca/binding/jms/ExceptionsTestCase.java | 212 +++ .../sca-java-2.0-M4/itest/jms/exceptions1/pom.xml | 83 + .../tuscany/sca/binding/jms/CheckedExcpetion.java | 28 + .../sca/binding/jms/CheckedExcpetion2Args.java | 28 + .../sca/binding/jms/CheckedExcpetionChained.java | 28 + .../sca/binding/jms/CheckedExcpetionNoArgs.java | 28 + .../tuscany/sca/binding/jms/ExceptionService.java | 33 + .../sca/binding/jms/ExceptionServiceClient.java | 57 + .../sca/binding/jms/ExceptionServiceImpl.java | 44 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/exceptions/client.composite | 31 + .../main/resources/exceptions/service.composite | 31 + .../exceptions1/src/main/resources/jndi.properties | 39 + .../sca/binding/jms/ExceptionsTestCase.java | 110 ++ .../itest/jms/externalBroker/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/external/client.composite | 36 + .../src/main/resources/external/service.composite | 36 + .../src/main/resources/jndi.properties | 39 + .../sca/binding/jms/ExternalBrokerTestCase.java | 71 + .../itest/jms/format-jmsbytes/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmsbytes/helloworld.composite | 45 + .../src/main/resources/jndi.properties | 39 + .../binding/jms/format/FormatJMSBytesTestCase.java | 69 + .../itest/jms/format-jmsbytesxml/pom.xml | 83 + .../jmsbytesxml/helloworld/CheckedException.java | 28 + .../helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 + .../jmsbytesxml/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 39 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../resources/jmsbytesxml/helloworld.composite | 45 + .../src/main/resources/jndi.properties | 39 + .../jms/format/FormatJMSBytesXMLTestCase.java | 58 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../itest/jms/format-jmsdefault/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmsdefault/helloworld/CheckedException.java | 28 + .../jmsdefault/helloworld/HelloWorldReference.java | 36 + .../helloworld/HelloWorldReferenceImpl.java | 85 + .../jmsdefault/helloworld/HelloWorldService.java | 38 + .../helloworld/HelloWorldServiceImpl.java | 51 + .../jms/format/jmsdefault/helloworld/Person.java | 42 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmsdefault/helloworld.composite | 94 ++ .../src/main/resources/jmsdefault/helloworld.wsdl | 139 ++ .../src/main/resources/jndi.properties | 39 + .../jms/format/FormatJMSDefaultTestCase.java | 68 + .../itest/jms/format-jmsmessage/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmsmessage/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 41 + .../jmsmessage/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 51 + .../helloworld/HelloWorldServiceReferenceSide.java | 37 + .../jms/format/jmsmessage/helloworld/README | 3 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmsmessage/helloworld.composite | 46 + .../src/main/resources/jmsmessage/helloworld.wsdl | 129 ++ .../src/main/resources/jndi.properties | 39 + .../jms/format/FormatJMSMessageTestCase.java | 58 + .../itest/jms/format-jmsobject/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmsobject/helloworld/CheckedException.java | 28 + .../jmsobject/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 112 ++ .../jmsobject/helloworld/HelloWorldService.java | 41 + .../helloworld/HelloWorldServiceImpl.java | 63 + .../jms/format/jmsobject/helloworld/Person.java | 47 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmsobject/helloworld.composite | 62 + .../src/main/resources/jmsobject/helloworld.wsdl | 368 +++++ .../src/main/resources/jndi.properties | 39 + .../jms/format/FormatJMSObjectTestCase.java | 73 + .../itest/jms/format-jmstext/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmstext/helloworld/CheckedException.java | 28 + .../jmstext/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 + .../jmstext/helloworld/HelloWorldService.java | 35 + .../jmstext/helloworld/HelloWorldServiceImpl.java | 38 + .../helloworld/HelloWorldServiceReference.java | 35 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmstext/helloworld.composite | 45 + .../src/main/resources/jndi.properties | 39 + .../binding/jms/format/FormatJMSTextTestCase.java | 60 + .../itest/jms/format-jmstextxml/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmstextxml/helloworld/CheckedException.java | 28 + .../jmstextxml/helloworld/HelloWorldReference.java | 33 + .../helloworld/HelloWorldReferenceImpl.java | 62 + .../jmstextxml/helloworld/HelloWorldService.java | 35 + .../helloworld/HelloWorldServiceImpl.java | 44 + .../jms/format/jmstextxml/helloworld/Person.java | 42 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/jmstextxml/helloworld.composite | 80 + .../src/main/resources/jmstextxml/helloworld.wsdl | 153 ++ .../src/main/resources/jndi.properties | 39 + .../jms/format/FormatJMSTextXMLTestCase.java | 62 + .../jms/format-jmstextxmlinjmsobjectout/pom.xml | 83 + .../jmsbytes/helloworld/CheckedException.java | 28 + .../jmsbytes/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 50 + .../jmsbytes/helloworld/HelloWorldService.java | 35 + .../jmsbytes/helloworld/HelloWorldServiceImpl.java | 40 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmsbytesxml/helloworld/CheckedException.java | 28 + .../helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 + .../jmsbytesxml/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 39 + .../jmsdefault/helloworld/CheckedException.java | 28 + .../jmsdefault/helloworld/HelloWorldReference.java | 36 + .../helloworld/HelloWorldReferenceImpl.java | 85 + .../jmsdefault/helloworld/HelloWorldService.java | 38 + .../helloworld/HelloWorldServiceImpl.java | 51 + .../jms/format/jmsdefault/helloworld/Person.java | 42 + .../jmsmessage/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 41 + .../jmsmessage/helloworld/HelloWorldService.java | 34 + .../helloworld/HelloWorldServiceImpl.java | 51 + .../helloworld/HelloWorldServiceReferenceSide.java | 37 + .../jms/format/jmsmessage/helloworld/README | 3 + .../jmsobject/helloworld/CheckedException.java | 28 + .../jmsobject/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 112 ++ .../jmsobject/helloworld/HelloWorldService.java | 41 + .../helloworld/HelloWorldServiceImpl.java | 63 + .../jms/format/jmsobject/helloworld/Person.java | 47 + .../jmstext/helloworld/CheckedException.java | 28 + .../jmstext/helloworld/HelloWorldReference.java | 32 + .../helloworld/HelloWorldReferenceImpl.java | 46 + .../jmstext/helloworld/HelloWorldService.java | 35 + .../jmstext/helloworld/HelloWorldServiceImpl.java | 38 + .../helloworld/HelloWorldServiceReference.java | 35 + .../jmstextxml/helloworld/CheckedException.java | 28 + .../jmstextxml/helloworld/HelloWorldReference.java | 33 + .../helloworld/HelloWorldReferenceImpl.java | 62 + .../jmstextxml/helloworld/HelloWorldService.java | 35 + .../helloworld/HelloWorldServiceImpl.java | 44 + .../jms/format/jmstextxml/helloworld/Person.java | 42 + .../helloworld/HelloWorldReferenceImpl.java | 38 + .../helloworld/HelloWorldService.java | 33 + .../helloworld/HelloWorldServiceImpl.java | 35 + .../helloworld/Person.java | 42 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../jmstextxmlinjmsobjectout/helloworld.composite | 52 + .../jmstextxmlinjmsobjectout/helloworld.wsdl | 139 ++ .../src/main/resources/jndi.properties | 39 + .../FormatJMSTextXMLInJMSObjectOutTestCase.java | 62 + .../itest/jms/non-sca-client/pom.xml | 83 + .../sca/binding/jms/OneWayObjectService.java | 29 + .../sca/binding/jms/OneWayObjectServiceImpl.java | 34 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/jndi.properties | 39 + .../main/resources/nonSCAclient/service.composite | 54 + .../sca/binding/jms/NonSCAClientTestCase.java | 144 ++ .../sca-java-2.0-M4/itest/jms/noreplyto/pom.xml | 83 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../noreplyto/src/main/resources/jndi.properties | 39 + .../noreplyto/src/main/resources/service.composite | 38 + .../tuscany/sca/binding/jms/NoReplyToTestCase.java | 100 ++ branches/sca-java-2.0-M4/itest/jms/nulls/pom.xml | 71 + .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../apache/tuscany/sca/binding/jms/MyService.java | 28 + .../tuscany/sca/binding/jms/ServiceImpl.java | 28 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../jms/nulls/src/main/resources/jndi.properties | 38 + .../jms/nulls/src/main/resources/nulls.composite | 57 + .../tuscany/sca/binding/jms/NullsTestCase.java | 60 + .../sca-java-2.0-M4/itest/jms/oneway-nocf/pom.xml | 83 + .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../oneway-nocf/src/main/resources/jndi.properties | 38 + .../main/resources/oneway/OneWayClient.composite | 35 + .../main/resources/oneway/OneWayService.composite | 34 + .../tuscany/sca/binding/jms/OneWayTestCase.java | 59 + branches/sca-java-2.0-M4/itest/jms/oneway/pom.xml | 83 + .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../sca/binding/jms/OneWayObjectService.java | 29 + .../sca/binding/jms/OneWayObjectServiceImpl.java | 34 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../jms/oneway/src/main/resources/jndi.properties | 39 + .../main/resources/oneway/OneWayClient.composite | 33 + .../main/resources/oneway/OneWayService.composite | 33 + .../tuscany/sca/binding/jms/OneWayTestCase.java | 60 + .../itest/jms/policy-headers/pom.xml | 83 + .../apache/tuscany/sca/binding/jms/JMSClient.java | 28 + .../apache/tuscany/sca/binding/jms/MsgClient.java | 29 + .../tuscany/sca/binding/jms/MsgClientImpl.java | 38 + .../tuscany/sca/binding/jms/MsgClientService.java | 33 + .../apache/tuscany/sca/binding/jms/MsgService.java | 32 + .../tuscany/sca/binding/jms/MsgServiceImpl.java | 39 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/jndi.properties | 39 + .../main/resources/policyHeaders/definitions.xml | 54 + .../policyHeaders/policyHeaders.composite | 45 + .../sca/binding/jms/PolicyHeadersTestCase.java | 94 ++ branches/sca-java-2.0-M4/itest/jms/pom.xml | 68 + .../sca-java-2.0-M4/itest/jms/properties/pom.xml | 83 + .../apache/tuscany/sca/binding/jms/JMSClient.java | 28 + .../apache/tuscany/sca/binding/jms/MsgClient.java | 29 + .../tuscany/sca/binding/jms/MsgClientImpl.java | 38 + .../tuscany/sca/binding/jms/MsgClientService.java | 33 + .../apache/tuscany/sca/binding/jms/MsgService.java | 32 + .../tuscany/sca/binding/jms/MsgServiceImpl.java | 39 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../properties/src/main/resources/jndi.properties | 39 + .../main/resources/properties/properties.composite | 53 + .../sca/binding/jms/PropertiesTestCase.java | 93 ++ .../sca-java-2.0-M4/itest/jms/responsecf/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../src/main/resources/cf/client.composite | 36 + .../src/main/resources/cf/service.composite | 36 + .../responsecf/src/main/resources/jndi.properties | 39 + .../sca/binding/jms/ResponseCFTestCase.java | 53 + branches/sca-java-2.0-M4/itest/jms/rpc/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../jms/rpc/src/main/resources/jndi.properties | 39 + .../rpc/src/main/resources/simple/client.composite | 37 + .../src/main/resources/simple/service.composite | 37 + .../tuscany/sca/binding/jms/RPCTestCase.java | 53 + .../sca-java-2.0-M4/itest/jms/selectors/pom.xml | 70 + .../apache/tuscany/sca/binding/jms/ClientImpl.java | 41 + .../tuscany/sca/binding/jms/SelectorService.java | 29 + .../sca/binding/jms/SelectorServiceImpl1.java | 40 + .../sca/binding/jms/SelectorServiceImpl2.java | 38 + .../sca/binding/jms/SelectorServiceImpl3.java | 38 + .../jmsdefault/HelloWorldReference.java | 32 + .../jmsdefault/HelloWorldReferenceImpl.java | 39 + .../jmsdefault/HelloWorldService.java | 38 + .../jmsdefault/HelloWorldServiceImpl.java | 47 + .../jmsuserprop/HelloWorldReference.java | 32 + .../jmsuserprop/HelloWorldReferenceImpl.java | 36 + .../jmsuserprop/HelloWorldService.java | 38 + .../jmsuserprop/HelloWorldServiceImpl.java | 47 + .../main/resources/META-INF/sca-contribution.xml | 25 + .../main/resources/jmsdefault/helloworld.composite | 69 + .../resources/jmsuserprop/helloworld.composite | 65 + .../selectors/src/main/resources/jndi.properties | 38 + .../main/resources/selectors/selectors.composite | 68 + .../jms/OperationselectorJMSDefaultTestCase.java | 57 + .../jms/OperationselectorJMSUserPropTestCase.java | 57 + .../tuscany/sca/binding/jms/SelectorsTestCase.java | 76 + branches/sca-java-2.0-M4/itest/jms/topics/pom.xml | 71 + .../tuscany/sca/binding/jms/OneWayClientImpl.java | 41 + .../tuscany/sca/binding/jms/OneWayService.java | 29 + .../tuscany/sca/binding/jms/OneWayServiceImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../jms/topics/src/main/resources/jndi.properties | 38 + .../main/resources/topics/TopicsClient.composite | 33 + .../main/resources/topics/TopicsService.composite | 33 + .../tuscany/sca/binding/jms/TopicsTestCase.java | 59 + branches/sca-java-2.0-M4/itest/jms/ttl/pom.xml | 71 + .../main/java/itest/MockInitialContextFactory.java | 904 +++++++++++ .../tuscany/sca/binding/jms/ClientIface.java | 30 + .../apache/tuscany/sca/binding/jms/ClientImpl.java | 39 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../jms/ttl/src/main/resources/jndi.properties | 38 + .../itest/jms/ttl/src/main/resources/ttl.composite | 35 + .../tuscany/sca/binding/jms/TTLTestCase.java | 64 + branches/sca-java-2.0-M4/itest/jms/uri-rpc/pom.xml | 83 + .../sca/binding/jms/HelloWorldClientImpl.java | 41 + .../tuscany/sca/binding/jms/HelloWorldService.java | 26 + .../sca/binding/jms/HelloWorldServiceImpl.java | 30 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../jms/uri-rpc/src/main/resources/jndi.properties | 39 + .../src/main/resources/simple/service.composite | 37 + .../src/main/resources/simple/uriclient.composite | 31 + .../tuscany/sca/binding/jms/URIRPCTestCase.java | 54 + .../itest/nodes/helloworld-client/pom.xml | 44 + .../src/main/java/itest/nodes/HelloworldImpl.java | 43 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/helloworld-client.composite | 29 + .../itest/nodes/helloworld-iface/pom.xml | 39 + .../src/main/java/itest/nodes/Helloworld.java | 29 + .../itest/nodes/helloworld-service/pom.xml | 49 + .../src/main/java/itest/nodes/HelloworldImpl.java | 28 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../main/resources/helloworld-service.composite | 28 + .../itest/nodes/one-node-test/pom.xml | 48 + .../src/test/java/itest/OneNodeTestCase.java | 87 + branches/sca-java-2.0-M4/itest/nodes/pom.xml | 45 + .../itest/nodes/two-nodes-test/pom.xml | 58 + .../src/test/java/itest/ClientNode.java | 92 ++ .../src/test/java/itest/ServiceNode.java | 58 + .../test/java/itest/StopStartNodesTestCase.java | 102 ++ .../src/test/java/itest/TestCaseRunner.java | 292 ++++ .../src/test/java/itest/TwoNodesTestCase.java | 105 ++ .../itest/nodes/two-nodes-two-vms-test/build.xml | 38 + .../nodes/two-nodes-two-vms-test/client-config.xml | 38 + .../itest/nodes/two-nodes-two-vms-test/client.xml | 33 + .../itest/nodes/two-nodes-two-vms-test/pom.xml | 117 ++ .../nodes/two-nodes-two-vms-test/server-config.xml | 38 + .../itest/nodes/two-nodes-two-vms-test/server.xml | 33 + .../src/test/java/itest/TwoNodesTestCase.java | 57 + .../itest/operation-overloading/pom.xml | 53 + .../sca/test/opoverload/OverloadASourceTarget.java | 61 + .../sca/test/opoverload/impl/OverloadASource.java | 113 ++ .../sca/test/opoverload/impl/OverloadATarget.java | 99 ++ .../src/main/resources/OperationOverload.composite | 34 + .../test/opoverload/impl/OverloadATestCase.java | 98 ++ branches/sca-java-2.0-M4/itest/policies/pom.xml | 59 + .../tuscany/sca/itest/policies/CreditCard.java | 65 + .../sca/itest/policies/CreditCardPayment.java | 37 + .../tuscany/sca/itest/policies/Customer.java | 51 + .../sca/itest/policies/CustomerRegistry.java | 27 + .../apache/tuscany/sca/itest/policies/Payment.java | 30 + .../itest/policies/impl/CreditCardPaymentImpl.java | 40 + .../itest/policies/impl/CustomerRegistryImpl.java | 78 + .../sca/itest/policies/impl/PaymentImpl.java | 54 + .../policies/src/main/resources/Customer.composite | 34 + .../src/main/resources/LoggingMessages.properties | 16 + .../src/main/resources/META-INF/definitions.xml | 46 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../policies/src/main/resources/Payment.composite | 49 + .../sca/itest/policies/PaymentTestCase.java | 69 + branches/sca-java-2.0-M4/itest/pom.xml | 167 ++ branches/sca-java-2.0-M4/itest/properties/pom.xml | 74 + .../java/mysca/test/myservice/impl/MyService.java | 34 + .../mysca/test/myservice/impl/MyServiceImpl.java | 88 ++ .../test/myservice/impl/MyTotalServiceImpl.java | 46 + .../apache/tuscany/sca/itest/ABCDComponent.java | 50 + .../tuscany/sca/itest/ABCDComponentImpl.java | 73 + .../org/apache/tuscany/sca/itest/ABComponent.java | 75 + .../apache/tuscany/sca/itest/ABComponentImpl.java | 131 ++ .../org/apache/tuscany/sca/itest/CDComponent.java | 71 + .../apache/tuscany/sca/itest/CDComponentImpl.java | 143 ++ .../tuscany/sca/itest/ComplexPropertyBean.java | 151 ++ .../apache/tuscany/sca/itest/OverrideService.java | 27 + .../tuscany/sca/itest/OverrideServiceImpl.java | 28 + .../tuscany/sca/itest/PropertyComponent.java | 114 ++ .../tuscany/sca/itest/PropertyComponentImpl.java | 144 ++ .../apache/tuscany/sca/itest/PropertyService.java | 27 + .../java/org/apache/tuscany/sca/itest/cdi/Bar.java | 23 + .../org/apache/tuscany/sca/itest/cdi/Foo1.java | 39 + .../org/apache/tuscany/sca/itest/cdi/Foo2.java | 39 + .../org/apache/tuscany/sca/itest/cdi/Foo3.java | 44 + .../main/java/test/jaxb/props/ObjectFactory.java | 75 + .../java/test/jaxb/props/ReturnCodeProperties.java | 103 ++ .../main/java/test/jaxb/props/package-info.java | 27 + .../ConstructorPropertyInjection.composite | 39 + .../properties/src/main/resources/Outer.composite | 43 + .../src/main/resources/OuterPropertyTest.composite | 42 + .../src/main/resources/PropertyTest.composite | 260 +++ .../properties/src/main/resources/customer.xsd | 30 + .../properties/src/main/resources/fileProperty.txt | 21 + .../src/main/resources/manyValuesFileProperty.txt | 23 + .../src/main/resources/mySimpleService.composite | 40 + .../properties/src/main/resources/rcProps.txt | 22 + .../properties/src/main/resources/rcprops.xsd | 55 + .../tuscany/sca/itest/MyTotalServiceTestCase.java | 104 ++ .../tuscany/sca/itest/OuterPropertyTestCase.java | 169 ++ .../apache/tuscany/sca/itest/PropertyTestCase.java | 422 +++++ .../cdi/ConstructorPropertyInjectionTestCase.java | 72 + .../itest/recursive-multi-level/pom.xml | 61 + .../main/java/mysca/test/myservice/MyService.java | 26 + .../java/mysca/test/myservice/MyServiceImpl.java | 42 + .../mysca/test/myservice/MySimpleTotalService.java | 26 + .../test/myservice/MySimpleTotalServiceImpl.java | 39 + .../src/main/resources/TotalService1Auto.composite | 52 + .../src/main/resources/TotalService2Auto.composite | 49 + .../src/main/resources/TotalService3Auto.composite | 52 + .../java/test/sca/tests/MultiLevelTestCase.java | 90 ++ branches/sca-java-2.0-M4/itest/references/pom.xml | 52 + .../tuscany/sca/itest/references/AComponent.java | 40 + .../sca/itest/references/AComponentImpl.java | 125 ++ .../tuscany/sca/itest/references/BComponent.java | 26 + .../sca/itest/references/BComponentImpl.java | 39 + .../references/BComponentWrongTargetImpl.java | 39 + .../tuscany/sca/itest/references/CComponent.java | 24 + .../sca/itest/references/CComponentImpl.java | 27 + .../tuscany/sca/itest/references/DComponent.java | 26 + .../sca/itest/references/DComponentImpl.java | 35 + .../resources/AutoWiredReferencesTest.composite | 61 + .../main/resources/InnerReferencesTest.composite | 51 + .../resources/ManualWiredReferencesTest.composite | 59 + .../references/AutoWiredReferenceTestCase.java | 114 ++ .../itest/references/InnerReferenceTestCase.java | 99 ++ .../references/ManualWiredReferenceTestCase.java | 97 ++ .../sca-java-2.0-M4/itest/scaclient-api/pom.xml | 46 + .../src/main/java/itest/HelloworldService.java | 25 + .../src/main/java/itest/HelloworldServiceImpl.java | 38 + .../src/main/resources/Helloworld.composite | 29 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../java/test/scaclient/SCAClientTestCase.java | 61 + branches/sca-java-2.0-M4/itest/scdl/pom.xml | 79 + .../sca/itest/scdl/ContributionTestCase.java | 80 + .../tuscany/sca/itest/scdl/SCDLTestCase.java | 87 + .../itest/scdl/ValidateDependenciesTestCase.java | 73 + .../itest/scdl/src/test/resources/test.composite | 51 + branches/sca-java-2.0-M4/itest/scopes/pom.xml | 54 + .../scopes/CompositeScopeStateVerifierImpl.java | 46 + .../tuscany/sca/itest/scopes/StateVerifier.java | 25 + .../scopes/src/main/resources/scopes.composite | 29 + .../org/apache/tuscany/sca/test/ScopeTestCase.java | 89 ++ .../itest/service-reference/pom.xml | 66 + .../tuscany/sca/itest/serviceref/AComponent.java | 39 + .../sca/itest/serviceref/AComponentImpl.java | 112 ++ .../tuscany/sca/itest/serviceref/BComponent.java | 31 + .../sca/itest/serviceref/BComponentImpl.java | 38 + .../tuscany/sca/itest/serviceref/Base64Binary.java | 297 ++++ .../tuscany/sca/itest/serviceref/CComponent.java | 27 + .../sca/itest/serviceref/CComponentImpl.java | 30 + .../tuscany/sca/itest/serviceref/DComponent.java | 30 + .../sca/itest/serviceref/DComponentImpl.java | 64 + .../src/main/resources/nodeA/CompositeA.composite | 44 + .../src/main/resources/nodeB/CompositeB.composite | 46 + .../ServiceReferenceTest.composite | 48 + .../CallableReferenceRemoteTestCase.java | 139 ++ .../itest/serviceref/ServiceReferenceTestCase.java | 88 ++ branches/sca-java-2.0-M4/itest/services/pom.xml | 53 + .../tuscany/sca/itest/services/AComponent.java | 27 + .../tuscany/sca/itest/services/AComponentImpl.java | 28 + .../tuscany/sca/itest/services/BComponent.java | 25 + .../tuscany/sca/itest/services/BComponentImpl.java | 31 + .../tuscany/sca/itest/services/CComponent.java | 27 + .../tuscany/sca/itest/services/CComponentImpl.java | 28 + .../tuscany/sca/itest/services/D1Component.java | 24 + .../tuscany/sca/itest/services/DComponent.java | 24 + .../tuscany/sca/itest/services/DComponentImpl.java | 34 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/ServicesTest.composite | 70 + .../sca/itest/services/ServicesTestCase.java | 108 ++ branches/sca-java-2.0-M4/itest/wires/pom.xml | 53 + .../org/apache/tuscany/sca/itest/WireClient.java | 34 + .../apache/tuscany/sca/itest/WireClientImpl.java | 51 + .../org/apache/tuscany/sca/itest/WireService.java | 36 + .../apache/tuscany/sca/itest/WireServiceImpl.java | 39 + .../wires/src/main/resources/WireTest.composite | 39 + .../org/apache/tuscany/sca/itest/WireTestCase.java | 78 + .../sca-java-2.0-M4/modules/assembly-xml/LICENSE | 205 +++ .../modules/assembly-xml/META-INF/MANIFEST.MF | 70 + .../sca-java-2.0-M4/modules/assembly-xml/NOTICE | 6 + .../sca-java-2.0-M4/modules/assembly-xml/pom.xml | 80 + .../sca/assembly/xml/BaseAssemblyProcessor.java | 782 +++++++++ .../xml/ComponentTypeDocumentProcessor.java | 129 ++ .../assembly/xml/ComponentTypeModelResolver.java | 96 ++ .../sca/assembly/xml/ComponentTypeProcessor.java | 378 +++++ .../assembly/xml/CompositeDocumentProcessor.java | 147 ++ .../sca/assembly/xml/CompositeModelResolver.java | 93 ++ .../sca/assembly/xml/CompositeProcessor.java | 1065 +++++++++++++ .../assembly/xml/ConfiguredOperationProcessor.java | 107 ++ .../apache/tuscany/sca/assembly/xml/Constants.java | 97 ++ .../assembly/xml/DefaultBeanModelProcessor.java | 252 +++ .../sca/assembly/xml/EndpointProcessor.java | 122 ++ .../assembly/xml/EndpointReferenceProcessor.java | 148 ++ .../apache/tuscany/sca/assembly/xml/Messages.java | 27 + .../sca/assembly/xml/PolicySubjectProcessor.java | 241 +++ .../sca/assembly/xml/SCABindingProcessor.java | 131 ++ .../xml/DefaultDefinitionsExtensionPoint.java | 128 ++ .../xml/DefinitionsDocumentProcessor.java | 171 ++ .../definitions/xml/DefinitionsExtensionPoint.java | 64 + .../sca/definitions/xml/DefinitionsProcessor.java | 230 +++ .../tuscany/sca/definitions/xml/Messages.java | 27 + .../sca/policy/xml/BindingTypeProcessor.java | 65 + .../sca/policy/xml/ExtensionTypeProcessor.java | 250 +++ .../policy/xml/ImplementationTypeProcessor.java | 65 + .../tuscany/sca/policy/xml/IntentProcessor.java | 392 +++++ .../apache/tuscany/sca/policy/xml/Messages.java | 27 + .../tuscany/sca/policy/xml/PolicyConstants.java | 74 + .../tuscany/sca/policy/xml/PolicySetProcessor.java | 510 ++++++ .../sca/policy/xml/PolicyXPathFunction.java | 158 ++ .../policy/xml/PolicyXPathFunctionResolver.java | 72 + .../sca-policy-1.1-intents-definitions-cd03.xml | 242 +++ ...ca.contribution.processor.StAXArtifactProcessor | 28 + ...sca.contribution.processor.URLArtifactProcessor | 21 + ...tuscany.sca.contribution.resolver.ModelResolver | 20 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...y.sca.definitions.xml.DefinitionsExtensionPoint | 17 + .../assembly-xml-validation-messages.properties | 31 + .../definitions-xml-validation-messages.properties | 22 + .../xml/policy-xml-validation-messages.properties | 45 + .../xml/MultiplicityReadWriteTestCase.java | 88 ++ .../tuscany/sca/assembly/xml/ReadAllTestCase.java | 151 ++ .../sca/assembly/xml/ReadDocumentTestCase.java | 191 +++ .../tuscany/sca/assembly/xml/ReadTestCase.java | 85 + .../xml/ReadWriteAnyAttributeTestCase.java | 130 ++ .../assembly/xml/ReadWriteAnyElementTestCase.java | 151 ++ .../xml/ReadWriteLocalCompositeTestCase.java | 103 ++ .../sca/assembly/xml/ResolvePolicyTestCase.java | 143 ++ .../tuscany/sca/assembly/xml/ResolveTestCase.java | 82 + .../sca/assembly/xml/TestAttributeProcessor.java | 62 + .../sca/assembly/xml/TestPolicyProcessor.java | 83 + .../assembly/xml/TestSCABindingFactoryImpl.java | 40 + .../sca/assembly/xml/TestSCABindingImpl.java | 190 +++ .../tuscany/sca/assembly/xml/WireTestCase.java | 109 ++ .../tuscany/sca/assembly/xml/WriteAllTestCase.java | 136 ++ .../sca/assembly/xml/WriteNamespacesTestCase.java | 99 ++ .../tuscany/sca/definitions/xml/MockPolicy.java | 39 + .../sca/definitions/xml/ReadDocumentTestCase.java | 230 +++ .../sca/definitions/xml/TestPolicyProcessor.java | 58 + .../xml/PolicyXPathFunctionResolverTestCase.java | 136 ++ .../sca/policy/xml/ReadDocumentTestCase.java | 286 ++++ .../sca/policy/xml/TestPolicyProcessor.java | 83 + .../tuscany/sca/assembly/xml/Calculator.composite | 59 + .../sca/assembly/xml/CalculatorImpl.componentType | 31 + .../sca/assembly/xml/Multiplicity.composite | 32 + .../sca/assembly/xml/NestedCalculator.composite | 29 + .../sca/assembly/xml/RMIBindingTest.composite | 44 + .../sca/assembly/xml/TestAllCalculator.composite | 127 ++ .../sca/assembly/xml/TestAllDivide.composite | 56 + .../assembly/xml/TestAllPolicyCalculator.composite | 125 ++ .../sca/assembly/xml/another_test_definitions.xml | 96 ++ .../tuscany/sca/assembly/xml/local.composite | 27 + .../tuscany/sca/assembly/xml/test_definitions.xml | 206 +++ .../sca/definitions/xml/test_definitions.xml | 207 +++ .../tuscany/sca/policy/xml/Calculator.composite | 49 + .../tuscany/sca/policy/xml/test_definitions.xml | 204 +++ .../sca-java-2.0-M4/modules/assembly-xsd/LICENSE | 337 ++++ .../modules/assembly-xsd/META-INF/MANIFEST.MF | 15 + .../sca-java-2.0-M4/modules/assembly-xsd/NOTICE | 38 + .../sca-java-2.0-M4/modules/assembly-xsd/pom.xml | 31 + .../apache/tuscany/sca/assembly/xsd/Constants.java | 138 ++ ...any.sca.contribution.processor.ValidationSchema | 18 + .../apache/tuscany/sca/assembly/xsd/XMLSchema.dtd | 402 +++++ .../apache/tuscany/sca/assembly/xsd/datatypes.dtd | 204 +++ .../xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd | 195 +++ .../oasis-200401-wss-wssecurity-utility-1.0.xsd | 108 ++ .../apache/tuscany/sca/assembly/xsd/ws-addr.xsd | 137 ++ .../apache/tuscany/sca/assembly/xsd/ws-policy.xsd | 141 ++ .../org/apache/tuscany/sca/assembly/xsd/wsdli.xsd | 35 + .../org/apache/tuscany/sca/assembly/xsd/xml.xsd | 117 ++ .../sca/assembly/xsd/xmldsig-core-schema.xsd | 318 ++++ .../src/main/resources/sca-1.1-cd04.xsd | 39 + .../main/resources/sca-binding-ejb-1.1-cd01.xsd | 34 + .../main/resources/sca-binding-jca-1.1-cd04.xsd | 173 ++ .../main/resources/sca-binding-jms-1.1-cd04.xsd | 183 +++ .../main/resources/sca-binding-sca-1.1-cd04.xsd | 20 + .../src/main/resources/sca-binding-ws-1.1-cd04.xsd | 35 + .../resources/sca-binding-ws-callback-1.1-cd04.xsd | 18 + .../main/resources/sca-contribution-1.1-cd04.xsd | 90 ++ .../main/resources/sca-contribution-c-1.1-cd04.xsd | 35 + .../resources/sca-contribution-cpp-1.1-cd04.xsd | 35 + .../resources/sca-contribution-java-1.1-cd02.xsd | 33 + .../src/main/resources/sca-core-1.1-cd04.xsd | 534 +++++++ .../main/resources/sca-definitions-1.1-cd04.xsd | 31 + .../resources/sca-implementation-bpel-1.1-cd03.xsd | 32 + .../resources/sca-implementation-c-1.1-cd04.xsd | 57 + .../sca-implementation-composite-1.1-cd04.xsd | 26 + .../resources/sca-implementation-cpp-1.1-cd04.xsd | 54 + .../resources/sca-implementation-java-1.1-cd03.xsd | 27 + .../sca-implementation-spring-1.1-cd01.xsd | 21 + .../main/resources/sca-interface-c-1.1-cd04.xsd | 43 + .../main/resources/sca-interface-cpp-1.1-cd04.xsd | 44 + .../main/resources/sca-interface-java-1.1-cd04.xsd | 29 + .../main/resources/sca-interface-wsdl-1.1-cd04.xsd | 29 + .../src/main/resources/sca-jee-1.1-wd03.xsd | 52 + .../src/main/resources/sca-policy-1.1-cd04.xsd | 101 ++ .../main/resources/tuscany-sca-1.1-binding-dwr.xsd | 41 + .../resources/tuscany-sca-1.1-binding-http.xsd | 41 + .../resources/tuscany-sca-1.1-binding-jsonrpc.xsd | 41 + .../main/resources/tuscany-sca-1.1-binding-rmi.xsd | 40 + .../tuscany-sca-1.1-implementation-osgi.xsd | 53 + .../src/main/resources/tuscany-sca-1.1.xsd | 34 + branches/sca-java-2.0-M4/modules/assembly/LICENSE | 205 +++ .../modules/assembly/META-INF/MANIFEST.MF | 62 + branches/sca-java-2.0-M4/modules/assembly/NOTICE | 6 + branches/sca-java-2.0-M4/modules/assembly/pom.xml | 45 + .../tuscany/sca/assembly/AbstractContract.java | 77 + .../tuscany/sca/assembly/AbstractProperty.java | 122 ++ .../tuscany/sca/assembly/AbstractReference.java | 43 + .../tuscany/sca/assembly/AbstractService.java | 28 + .../tuscany/sca/assembly/AssemblyFactory.java | 166 ++ .../java/org/apache/tuscany/sca/assembly/Base.java | 44 + .../org/apache/tuscany/sca/assembly/Binding.java | 66 + .../apache/tuscany/sca/assembly/BindingRRB.java | 42 + .../org/apache/tuscany/sca/assembly/Callback.java | 39 + .../org/apache/tuscany/sca/assembly/Component.java | 141 ++ .../tuscany/sca/assembly/ComponentProperty.java | 88 ++ .../tuscany/sca/assembly/ComponentReference.java | 112 ++ .../tuscany/sca/assembly/ComponentService.java | 58 + .../apache/tuscany/sca/assembly/ComponentType.java | 89 ++ .../org/apache/tuscany/sca/assembly/Composite.java | 132 ++ .../tuscany/sca/assembly/CompositeReference.java | 44 + .../tuscany/sca/assembly/CompositeService.java | 56 + .../tuscany/sca/assembly/ConfiguredOperation.java | 61 + .../org/apache/tuscany/sca/assembly/Contract.java | 110 ++ .../sca/assembly/DefaultAssemblyFactory.java | 41 + .../sca/assembly/DistributedSCABinding.java | 45 + .../org/apache/tuscany/sca/assembly/Endpoint.java | 146 ++ .../tuscany/sca/assembly/EndpointReference.java | 189 +++ .../apache/tuscany/sca/assembly/Extensible.java | 44 + .../org/apache/tuscany/sca/assembly/Extension.java | 65 + .../tuscany/sca/assembly/Implementation.java | 35 + .../apache/tuscany/sca/assembly/Multiplicity.java | 49 + .../tuscany/sca/assembly/OperationSelector.java | 28 + .../sca/assembly/OperationsConfigurator.java | 33 + .../tuscany/sca/assembly/OptimizableBinding.java | 66 + .../org/apache/tuscany/sca/assembly/Property.java | 39 + .../org/apache/tuscany/sca/assembly/Reference.java | 87 + .../apache/tuscany/sca/assembly/SCABinding.java | 30 + .../tuscany/sca/assembly/SCABindingFactory.java | 37 + .../org/apache/tuscany/sca/assembly/Service.java | 41 + .../java/org/apache/tuscany/sca/assembly/Wire.java | 85 + .../apache/tuscany/sca/assembly/WireFormat.java | 28 + .../sca/assembly/builder/BindingBuilder.java | 50 + .../sca/assembly/builder/BuilderContext.java | 95 ++ .../assembly/builder/BuilderExtensionPoint.java | 118 ++ .../sca/assembly/builder/CompositeBuilder.java | 51 + .../builder/CompositeBuilderException.java | 45 + .../builder/DefaultBuilderExtensionPoint.java | 395 +++++ .../sca/assembly/builder/DomainBuilder.java | 83 + .../assembly/builder/ImplementationBuilder.java | 49 + .../tuscany/sca/assembly/builder/Messages.java | 30 + .../sca/assembly/builder/PolicyBuilder.java | 57 + .../sca/assembly/impl/AbstractPropertyImpl.java | 93 ++ .../sca/assembly/impl/AbstractReferenceImpl.java | 46 + .../sca/assembly/impl/AbstractServiceImpl.java | 36 + .../sca/assembly/impl/AssemblyFactoryImpl.java | 138 ++ .../apache/tuscany/sca/assembly/impl/BaseImpl.java | 45 + .../tuscany/sca/assembly/impl/BindingImpl.java | 99 ++ .../tuscany/sca/assembly/impl/CallbackImpl.java | 67 + .../tuscany/sca/assembly/impl/ComponentImpl.java | 186 +++ .../sca/assembly/impl/ComponentPropertyImpl.java | 97 ++ .../sca/assembly/impl/ComponentReferenceImpl.java | 119 ++ .../sca/assembly/impl/ComponentServiceImpl.java | 71 + .../sca/assembly/impl/ComponentTypeImpl.java | 167 ++ .../tuscany/sca/assembly/impl/CompositeImpl.java | 185 +++ .../sca/assembly/impl/CompositeReferenceImpl.java | 63 + .../sca/assembly/impl/CompositeServiceImpl.java | 62 + .../sca/assembly/impl/ConfiguredOperationImpl.java | 95 ++ .../tuscany/sca/assembly/impl/ContractImpl.java | 88 ++ .../assembly/impl/DistributedSCABindingImpl.java | 76 + .../tuscany/sca/assembly/impl/EndpointImpl.java | 202 +++ .../sca/assembly/impl/EndpointReferenceImpl.java | 250 +++ .../tuscany/sca/assembly/impl/ExtensibleImpl.java | 49 + .../tuscany/sca/assembly/impl/ExtensionImpl.java | 62 + .../sca/assembly/impl/ImplementationImpl.java | 76 + .../tuscany/sca/assembly/impl/PropertyImpl.java | 59 + .../tuscany/sca/assembly/impl/ReferenceImpl.java | 144 ++ .../sca/assembly/impl/SCABindingFactoryImpl.java | 45 + .../tuscany/sca/assembly/impl/SCABindingImpl.java | 168 ++ .../tuscany/sca/assembly/impl/ServiceImpl.java | 106 ++ .../apache/tuscany/sca/assembly/impl/WireImpl.java | 105 ++ .../sca/definitions/DefaultDefinitionsFactory.java | 32 + .../tuscany/sca/definitions/Definitions.java | 84 + .../sca/definitions/DefinitionsBuilder.java | 34 + .../definitions/DefinitionsBuilderException.java | 43 + .../sca/definitions/DefinitionsFactory.java | 31 + .../definitions/impl/DefinitionsBuilderImpl.java | 307 ++++ .../sca/definitions/impl/DefinitionsImpl.java | 73 + .../sca/definitions/util/DefinitionsUtil.java | 104 ++ .../sca/interfacedef/ConversationSequence.java | 29 + .../apache/tuscany/sca/interfacedef/DataType.java | 119 ++ .../sca/interfacedef/FaultExceptionMapper.java | 62 + .../IncompatibleInterfaceContractException.java | 69 + .../apache/tuscany/sca/interfacedef/Interface.java | 128 ++ .../sca/interfacedef/InterfaceContract.java | 81 + .../sca/interfacedef/InterfaceContractMapper.java | 139 ++ .../interfacedef/InvalidAnnotationException.java | 36 + .../sca/interfacedef/InvalidCallbackException.java | 34 + .../interfacedef/InvalidInterfaceException.java | 41 + .../interfacedef/InvalidOperationException.java | 42 + .../apache/tuscany/sca/interfacedef/Operation.java | 209 +++ .../interfacedef/OverloadedOperationException.java | 45 + .../sca/interfacedef/impl/DataTypeImpl.java | 219 +++ .../interfacedef/impl/InterfaceContractImpl.java | 128 ++ .../impl/InterfaceContractMapperImpl.java | 390 +++++ .../sca/interfacedef/impl/InterfaceImpl.java | 328 ++++ .../sca/interfacedef/impl/OperationImpl.java | 284 ++++ .../tuscany/sca/interfacedef/util/ElementInfo.java | 114 ++ .../sca/interfacedef/util/FaultException.java | 82 + .../sca/interfacedef/util/JavaXMLMapper.java | 143 ++ .../tuscany/sca/interfacedef/util/TypeInfo.java | 100 ++ .../tuscany/sca/interfacedef/util/WrapperInfo.java | 190 +++ .../tuscany/sca/interfacedef/util/XMLType.java | 152 ++ .../org/apache/tuscany/sca/policy/BindingType.java | 27 + .../tuscany/sca/policy/DefaultPolicyFactory.java | 30 + .../apache/tuscany/sca/policy/ExtensionType.java | 81 + .../tuscany/sca/policy/ImplementationType.java | 27 + .../java/org/apache/tuscany/sca/policy/Intent.java | 160 ++ .../org/apache/tuscany/sca/policy/IntentMap.java | 49 + .../tuscany/sca/policy/PolicyAttachment.java | 31 + .../tuscany/sca/policy/PolicyExpression.java | 65 + .../apache/tuscany/sca/policy/PolicyFactory.java | 66 + .../org/apache/tuscany/sca/policy/PolicySet.java | 146 ++ .../apache/tuscany/sca/policy/PolicySubject.java | 56 + .../org/apache/tuscany/sca/policy/Qualifier.java | 44 + .../tuscany/sca/policy/impl/BindingTypeImpl.java | 38 + .../tuscany/sca/policy/impl/ExtensionTypeImpl.java | 97 ++ .../sca/policy/impl/ImplementationTypeImpl.java | 39 + .../apache/tuscany/sca/policy/impl/IntentImpl.java | 168 ++ .../tuscany/sca/policy/impl/IntentMapImpl.java | 61 + .../sca/policy/impl/PolicyExpressionImpl.java | 86 + .../tuscany/sca/policy/impl/PolicyFactoryImpl.java | 70 + .../tuscany/sca/policy/impl/PolicySetImpl.java | 145 ++ .../tuscany/sca/policy/impl/QualifierImpl.java | 48 + .../tuscany/sca/policy/util/PolicyHelper.java | 97 ++ ...org.apache.tuscany.sca.assembly.AssemblyFactory | 18 + ...org.apache.tuscany.sca.assembly.EndpointFactory | 18 + ...g.apache.tuscany.sca.assembly.SCABindingFactory | 18 + ...cany.sca.assembly.builder.BuilderExtensionPoint | 18 + ...ache.tuscany.sca.definitions.DefinitionsFactory | 17 + ...uscany.sca.interfacedef.InterfaceContractMapper | 18 + .../org.apache.tuscany.sca.policy.PolicyFactory | 18 + .../assembly-conformance-messages.properties | 327 ++++ .../assembly-validation-messages.properties | 76 + .../assembly-validation-messages_it.properties | 30 + .../definitions-validation-messages.properties | 25 + .../sca/assembly/AssemblyFactoryTestCase.java | 170 ++ .../apache/tuscany/sca/assembly/TestBinding.java | 49 + .../tuscany/sca/assembly/TestImplementation.java | 61 + .../apache/tuscany/sca/assembly/TestInterface.java | 42 + .../sca/assembly/TestInterfaceContract.java | 41 + .../apache/tuscany/sca/assembly/TestOperation.java | 30 + .../impl/ContractCompatibilityTestCase.java | 395 +++++ .../impl/InterfaceContractTestCase.java | 70 + .../tuscany/sca/policy/PolicyFactoryTestCase.java | 55 + .../modules/binding-atom-runtime/LICENSE | 205 +++ .../binding-atom-runtime/META-INF/MANIFEST.MF | 48 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../modules/binding-atom-runtime/NOTICE | 6 + .../modules/binding-atom-runtime/pom.xml | 214 +++ .../sca/binding/atom/collection/Collection.java | 81 + .../binding/atom/collection/MediaCollection.java | 54 + .../binding/atom/collection/NotFoundException.java | 45 + .../binding/atom/provider/AtomBindingInvoker.java | 515 ++++++ .../atom/provider/AtomBindingListenerServlet.java | 914 +++++++++++ .../atom/provider/AtomBindingProviderFactory.java | 66 + .../sca/binding/atom/provider/AtomBindingUtil.java | 165 ++ .../provider/AtomReferenceBindingProvider.java | 178 +++ .../atom/provider/AtomServiceBindingProvider.java | 117 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../atom/AbstractProviderConsumerTestCase.java | 55 + .../sca/binding/atom/AtomDeleteTestCase.java | 118 ++ .../binding/atom/AtomFeedNonCollectionTest.java | 221 +++ .../tuscany/sca/binding/atom/AtomGetTestCase.java | 121 ++ .../tuscany/sca/binding/atom/AtomPostTestCase.java | 110 ++ .../tuscany/sca/binding/atom/AtomPutTestCase.java | 129 ++ .../apache/tuscany/sca/binding/atom/Consumer.java | 44 + .../binding/atom/ConsumerProviderAtomTestCase.java | 159 ++ .../sca/binding/atom/ContentNegotiationTest.java | 259 +++ .../tuscany/sca/binding/atom/CustomerClient.java | 33 + .../sca/binding/atom/CustomerClientImpl.java | 103 ++ .../sca/binding/atom/CustomerCollectionImpl.java | 153 ++ .../binding/atom/CustomerNonCollectionImpl.java | 55 + .../sca/binding/atom/MediaCollectionImpl.java | 213 +++ .../sca/binding/atom/MediaCollectionTestCase.java | 295 ++++ .../apache/tuscany/sca/binding/atom/Provider.java | 50 + .../atom/ProviderEntryEntityTagsTestCase.java | 433 +++++ .../atom/ProviderFeedEntityTagsTestCase.java | 387 +++++ .../atom/ProviderServiceDocumentTestCase.java | 204 +++ .../sca/binding/atom/aggregator/Aggregator.java | 35 + .../binding/atom/aggregator/AggregatorImpl.java | 135 ++ .../atom/aggregator/AggregatorTestCase.java | 83 + .../tuscany/sca/binding/atom/aggregator/Sort.java | 39 + .../sca/binding/atom/aggregator/SortImpl.java | 62 + .../tuscany/sca/binding/atom/news/Headline.java | 54 + .../tuscany/sca/binding/atom/news/NewsService.java | 28 + .../sca/binding/atom/news/NewsServiceImpl.java | 90 ++ .../sca/binding/atom/news/NewsServiceTestCase.java | 78 + .../sca/binding/atom/util/AtomTestCaseUtils.java | 98 ++ .../src/test/resources/ReceiptToms.gif | Bin 0 -> 14205 bytes .../src/test/resources/ReceiptValue.jpg | Bin 0 -> 21373 bytes .../tuscany/sca/binding/atom/Consumer.composite | 32 + .../tuscany/sca/binding/atom/Provider.composite | 36 + .../binding/atom/ProviderNonCollection.composite | 38 + .../sca/binding/atom/ReceiptProvider.composite | 36 + .../atom/aggregator/FeedAggregator.composite | 51 + .../tuscany/sca/binding/atom/news/news.composite | 32 + .../sca-java-2.0-M4/modules/binding-atom/LICENSE | 205 +++ .../modules/binding-atom/META-INF/MANIFEST.MF | 21 + ...che.tuscany.sca.binding.atom.AtomBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../sca-java-2.0-M4/modules/binding-atom/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-atom/pom.xml | 54 + .../tuscany/sca/binding/atom/AtomBinding.java | 59 + .../sca/binding/atom/AtomBindingFactory.java | 35 + .../binding/atom/impl/AtomBindingFactoryImpl.java | 36 + .../sca/binding/atom/impl/AtomBindingImpl.java | 93 ++ ...che.tuscany.sca.binding.atom.AtomBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../binding/atom/AtomBindingProcessorTestCase.java | 81 + .../modules/binding-ejb-runtime/LICENSE | 205 +++ .../binding-ejb-runtime/META-INF/MANIFEST.MF | 41 + .../modules/binding-ejb-runtime/NOTICE | 6 + .../modules/binding-ejb-runtime/pom.xml | 170 ++ .../sca/binding/ejb/corba/ClassLoadingUtil.java | 365 +++++ .../binding/ejb/corba/DynamicStubClassLoader.java | 150 ++ .../sca/binding/ejb/corba/Java2IDLUtil.java | 811 ++++++++++ .../binding/ejb/corba/ObjectInputStreamExt.java | 61 + .../binding/ejb/corba/StubMethodInterceptor.java | 154 ++ .../sca/binding/ejb/corba/UtilInitializer.java | 69 + .../binding/ejb/provider/EJBBindingInvoker.java | 92 ++ .../ejb/provider/EJBBindingProviderFactory.java | 56 + .../EJBBindingReferenceBindingProvider.java | 86 + .../tuscany/sca/binding/ejb/util/EJBHandler.java | 338 ++++ .../tuscany/sca/binding/ejb/util/EJBLocator.java | 483 ++++++ .../sca/binding/ejb/util/EJBObjectFactory.java | 209 +++ .../sca/binding/ejb/util/EJBStubHelper.java | 69 + .../sca/binding/ejb/util/InterfaceInfo.java | 117 ++ .../binding/ejb/util/JavaReflectionAdapter.java | 157 ++ .../tuscany/sca/binding/ejb/util/MethodInfo.java | 189 +++ .../sca/binding/ejb/util/NamingEndpoint.java | 124 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../binding-ejb-validation-messages.properties | 23 + .../src/test/java/account/BankManagerFacade.java | 33 + .../src/test/java/account/Customer.java | 36 + .../src/test/java/account/CustomerImpl.java | 57 + .../src/test/java/calculator/AddService.java | 27 + .../src/test/java/calculator/AddServiceHome.java | 31 + .../samples/bank/ejb/BankManagerFacade.java | 44 + .../samples/bank/ejb/BankManagerFacadeHome.java | 44 + .../binding/ejb/tests/EJBReferenceTestCase.java | 73 + .../tuscany/sca/binding/ejb/tests/MockServer.java | 151 ++ .../sca/binding/ejb/tests/SocketTracer.java | 138 ++ .../src/test/resources/account/account.composite | 37 + .../sca-java-2.0-M4/modules/binding-ejb/LICENSE | 205 +++ .../modules/binding-ejb/META-INF/MANIFEST.MF | 28 + .../sca-java-2.0-M4/modules/binding-ejb/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-ejb/pom.xml | 60 + .../apache/tuscany/sca/binding/ejb/EJBBinding.java | 85 + .../sca/binding/ejb/EJBBindingException.java | 56 + .../tuscany/sca/binding/ejb/EJBBindingFactory.java | 35 + .../binding/ejb/impl/EJBBindingFactoryImpl.java | 36 + .../sca/binding/ejb/impl/EJBBindingImpl.java | 180 +++ .../sca/binding/ejb/impl/EJBBindingProcessor.java | 167 ++ ...pache.tuscany.sca.binding.ejb.EJBBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + .../binding-ejb-validation-messages.properties | 23 + .../tuscany/sca/binding/ejb/policy/definitions.xml | 30 + .../modules/binding-http-runtime/LICENSE | 205 +++ .../binding-http-runtime/META-INF/MANIFEST.MF | 27 + .../modules/binding-http-runtime/NOTICE | 6 + .../modules/binding-http-runtime/pom.xml | 104 ++ .../http/provider/HTTPBindingListenerServlet.java | 453 ++++++ .../http/provider/HTTPBindingProviderFactory.java | 65 + .../http/provider/HTTPGetListenerServlet.java | 94 ++ .../http/provider/HTTPServiceBindingProvider.java | 212 +++ .../http/provider/HTTPServiceListenerServlet.java | 85 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../sca/binding/http/HTTPBindingCacheTestCase.java | 904 +++++++++++ .../sca/binding/http/HTTPBindingTestCase.java | 164 ++ .../sca/binding/http/NotModifiedException.java | 44 + .../binding/http/PreconditionFailedException.java | 44 + .../sca/binding/http/TestBindingCacheImpl.java | 241 +++ .../tuscany/sca/binding/http/TestGetImpl.java | 37 + .../sca/binding/http/TestServiceCacheImpl.java | 60 + .../tuscany/sca/binding/http/TestServiceImpl.java | 60 + .../src/test/resources/content/test.html | 21 + .../src/test/resources/test.composite | 47 + .../src/test/resources/testCache.composite | 33 + .../sca-java-2.0-M4/modules/binding-http/LICENSE | 205 +++ .../modules/binding-http/META-INF/MANIFEST.MF | 24 + .../sca-java-2.0-M4/modules/binding-http/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-http/pom.xml | 62 + .../tuscany/sca/binding/http/HTTPBinding.java | 34 + .../sca/binding/http/HTTPBindingFactory.java | 35 + .../tuscany/sca/binding/http/HTTPCacheContext.java | 257 +++ .../binding/http/impl/HTTPBindingFactoryImpl.java | 36 + .../sca/binding/http/impl/HTTPBindingImpl.java | 100 ++ .../sca/binding/http/xml/HTTPBindingProcessor.java | 142 ++ ...che.tuscany.sca.binding.http.HTTPBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../modules/binding-jms-runtime/LICENSE | 205 +++ .../binding-jms-runtime/META-INF/MANIFEST.MF | 38 + .../modules/binding-jms-runtime/NOTICE | 6 + .../modules/binding-jms-runtime/pom.xml | 117 ++ .../sca/binding/jms/context/JMSBindingContext.java | 141 ++ .../jms/headers/HeaderReferenceInterceptor.java | 167 ++ .../jms/host/DefaultJMSHostExtensionPoint.java | 40 + .../jms/host/DefaultJMSServiceListener.java | 234 +++ .../jms/host/DefaultJMSServiceListenerFactory.java | 55 + .../binding/jms/host/DefaultServiceInvoker.java | 93 ++ .../binding/jms/host/JMSHostExtensionPoint.java | 27 + .../sca/binding/jms/host/JMSServiceListener.java | 29 + .../jms/host/JMSServiceListenerDetails.java | 40 + .../jms/host/JMSServiceListenerFactory.java | 27 + ...OperationSelectorJMSDefaultProviderFactory.java | 66 + ...rationSelectorJMSDefaultServiceInterceptor.java | 190 +++ ...OperationSelectorJMSDefaultServiceProvider.java | 59 + ...perationSelectorJMSUserPropProviderFactory.java | 62 + ...ationSelectorJMSUserPropServiceInterceptor.java | 107 ++ ...perationSelectorJMSUserPropServiceProvider.java | 54 + ...MSTokenAuthenticationPolicyProviderFactory.java | 76 + ...enAuthenticationReferencePolicyInterceptor.java | 104 ++ ...TokenAuthenticationReferencePolicyProvider.java | 85 + ...okenAuthenticationServicePolicyInterceptor.java | 106 ++ ...MSTokenAuthenticationServicePolicyProvider.java | 85 + .../header/JMSHeaderPolicyProviderFactory.java | 82 + .../JMSHeaderReferencePolicyInterceptor.java | 87 + .../header/JMSHeaderReferencePolicyProvider.java | 86 + .../jms/provider/AbstractMessageProcessor.java | 136 ++ .../jms/provider/BytesMessageProcessor.java | 119 ++ .../DefaultJMSResourceFactoryExtensionPoint.java | 30 + .../jms/provider/DefaultMessageProcessor.java | 287 ++++ .../jms/provider/JMSBindingProviderFactory.java | 79 + .../JMSBindingReferenceBindingProvider.java | 166 ++ .../provider/JMSBindingServiceBindingProvider.java | 228 +++ .../binding/jms/provider/JMSMessageProcessor.java | 55 + .../jms/provider/JMSMessageProcessorUtil.java | 75 + .../binding/jms/provider/JMSResourceFactory.java | 95 ++ .../provider/JMSResourceFactoryExtensionPoint.java | 28 + .../jms/provider/JMSResourceFactoryImpl.java | 282 ++++ .../jms/provider/ObjectMessageProcessor.java | 230 +++ .../binding/jms/provider/RRBJMSBindingInvoker.java | 270 ++++ .../binding/jms/provider/TextMessageProcessor.java | 79 + .../jms/provider/XMLBytesMessageProcessor.java | 134 ++ .../jms/provider/XMLTextMessageProcessor.java | 129 ++ .../transport/TransportReferenceInterceptor.java | 158 ++ .../jms/transport/TransportServiceInterceptor.java | 185 +++ .../jms/wire/CallbackDestinationInterceptor.java | 94 ++ .../jms/wire/OperationPropertiesInterceptor.java | 69 + .../runtime/WireFormatJMSBytesProviderFactory.java | 66 + .../WireFormatJMSBytesReferenceInterceptor.java | 122 ++ .../WireFormatJMSBytesReferenceProvider.java | 100 ++ .../WireFormatJMSBytesServiceInterceptor.java | 114 ++ .../runtime/WireFormatJMSBytesServiceProvider.java | 104 ++ .../WireFormatJMSBytesXMLProviderFactory.java | 70 + .../WireFormatJMSBytesXMLReferenceInterceptor.java | 122 ++ .../WireFormatJMSBytesXMLReferenceProvider.java | 108 ++ .../WireFormatJMSBytesXMLServiceInterceptor.java | 108 ++ .../WireFormatJMSBytesXMLServiceProvider.java | 116 ++ .../WireFormatJMSDefaultProviderFactory.java | 69 + .../WireFormatJMSDefaultReferenceInterceptor.java | 174 ++ .../WireFormatJMSDefaultReferenceProvider.java | 202 +++ .../WireFormatJMSDefaultServiceInterceptor.java | 174 ++ .../WireFormatJMSDefaultServiceProvider.java | 194 +++ .../WireFormatJMSObjectProviderFactory.java | 66 + .../WireFormatJMSObjectReferenceInterceptor.java | 141 ++ .../WireFormatJMSObjectReferenceProvider.java | 119 ++ .../WireFormatJMSObjectServiceInterceptor.java | 138 ++ .../WireFormatJMSObjectServiceProvider.java | 125 ++ .../runtime/WireFormatJMSTextProviderFactory.java | 66 + .../WireFormatJMSTextReferenceInterceptor.java | 123 ++ .../WireFormatJMSTextReferenceProvider.java | 109 ++ .../WireFormatJMSTextServiceInterceptor.java | 114 ++ .../runtime/WireFormatJMSTextServiceProvider.java | 111 ++ .../WireFormatJMSTextXMLProviderFactory.java | 72 + .../WireFormatJMSTextXMLReferenceInterceptor.java | 128 ++ .../WireFormatJMSTextXMLReferenceProvider.java | 121 ++ .../WireFormatJMSTextXMLServiceInterceptor.java | 115 ++ .../WireFormatJMSTextXMLServiceProvider.java | 115 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + ...y.sca.provider.OperationSelectorProviderFactory | 20 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 + ....tuscany.sca.provider.WireFormatProviderFactory | 24 + .../sca/binding/jms/HelloWorldClientImpl.java | 43 + .../tuscany/sca/binding/jms/HelloWorldService.java | 31 + .../sca/binding/jms/HelloWorldServiceImpl.java | 32 + .../jms/OperationSelectionTestCaseFIXME.java | 229 +++ .../src/test/resources/simple/client.composite | 38 + .../src/test/resources/simple/service.composite | 35 + .../sca-java-2.0-M4/modules/binding-jms/LICENSE | 205 +++ .../modules/binding-jms/META-INF/MANIFEST.MF | 62 + .../sca-java-2.0-M4/modules/binding-jms/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-jms/pom.xml | 51 + .../tuscany/sca/binding/jms/BindingProperty.java | 71 + .../apache/tuscany/sca/binding/jms/JMSBinding.java | 974 ++++++++++++ .../sca/binding/jms/JMSBindingConstants.java | 75 + .../sca/binding/jms/JMSBindingException.java | 45 + .../sca/binding/jms/JMSBindingProcessor.java | 1541 ++++++++++++++++++ .../OperationSelectorJMSDefault.java | 45 + .../OperationSelectorJMSDefaultProcessor.java | 76 + .../OperationSelectorJMSUserProp.java | 57 + .../OperationSelectorJMSUserPropProcessor.java | 87 + .../token/JMSTokenAuthenticationPolicy.java | 55 + .../JMSTokenAuthenticationPolicyProcessor.java | 111 ++ .../binding/jms/policy/header/JMSHeaderPolicy.java | 130 ++ .../policy/header/JMSHeaderPolicyProcessor.java | 206 +++ .../binding/jms/wireformat/WireFormatJMSBytes.java | 45 + .../wireformat/WireFormatJMSBytesProcessor.java | 75 + .../jms/wireformat/WireFormatJMSBytesXML.java | 40 + .../wireformat/WireFormatJMSBytesXMLProcessor.java | 72 + .../jms/wireformat/WireFormatJMSDefault.java | 64 + .../wireformat/WireFormatJMSDefaultProcessor.java | 89 ++ .../jms/wireformat/WireFormatJMSObject.java | 57 + .../wireformat/WireFormatJMSObjectProcessor.java | 88 ++ .../binding/jms/wireformat/WireFormatJMSText.java | 45 + .../jms/wireformat/WireFormatJMSTextProcessor.java | 75 + .../jms/wireformat/WireFormatJMSTextXML.java | 48 + .../wireformat/WireFormatJMSTextXMLProcessor.java | 75 + ...ca.contribution.processor.StAXArtifactProcessor | 29 + ...che.tuscany.sca.provider.SCADefinitionsProvider | 19 + ...nding-jms-policy-validation-messages.properties | 23 + .../binding-jms-validation-messages.properties | 50 + .../tuscany/sca/binding/jms/policy/definitions.xml | 84 + .../binding/jms/JMSBindingProcessorTestCase.java | 773 +++++++++ .../jms/JMSBindingProcessorWriteTestCase.java | 438 +++++ .../jms/policy/PolicyProcessorTestCase.java | 95 ++ .../modules/binding-jsonp-runtime/LICENSE | 205 +++ .../binding-jsonp-runtime/META-INF/MANIFEST.MF | 33 + .../modules/binding-jsonp-runtime/NOTICE | 6 + .../modules/binding-jsonp-runtime/pom.xml | 97 ++ .../jsonp/runtime/JSONPBindingProviderFactory.java | 58 + .../sca/binding/jsonp/runtime/JSONPInvoker.java | 165 ++ .../runtime/JSONPReferenceBindingProvider.java | 53 + .../jsonp/runtime/JSONPServiceBindingProvider.java | 71 + .../sca/binding/jsonp/runtime/JSONPServlet.java | 162 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../src/test/java/helloworld/HelloWorldClient.java | 37 + .../src/test/java/helloworld/HelloWorldImpl.java | 32 + .../test/java/helloworld/HelloWorldService.java | 30 + .../src/test/java/test/BindingTestCase.java | 83 + .../src/test/resources/helloworld.composite | 39 + .../src/test/resources/jquery.html | 51 + .../sca-java-2.0-M4/modules/binding-jsonp/LICENSE | 205 +++ .../modules/binding-jsonp/META-INF/MANIFEST.MF | 18 + .../sca-java-2.0-M4/modules/binding-jsonp/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-jsonp/pom.xml | 41 + .../tuscany/sca/binding/jsonp/JSONPBinding.java | 31 + .../sca/binding/jsonp/JSONPBindingFactory.java | 31 + .../jsonp/impl/JSONPBindingFactoryImpl.java | 34 + .../sca/binding/jsonp/impl/JSONPBindingImpl.java | 67 + ...e.tuscany.sca.binding.jsonp.JSONPBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...any.sca.contribution.processor.ValidationSchema | 18 + .../src/main/resources/binding-jsonp.xsd | 41 + .../modules/binding-jsonrpc-runtime/LICENSE | 205 +++ .../binding-jsonrpc-runtime/META-INF/MANIFEST.MF | 44 + .../modules/binding-jsonrpc-runtime/NOTICE | 11 + .../modules/binding-jsonrpc-runtime/pom.xml | 143 ++ .../jsonrpc/provider/JSONRPCBindingInvoker.java | 147 ++ .../provider/JSONRPCBindingProviderFactory.java | 65 + .../jsonrpc/provider/JSONRPCClientInvoker.java | 74 + .../jsonrpc/provider/JSONRPCDatabindingHelper.java | 61 + .../provider/JSONRPCReferenceBindingProvider.java | 107 ++ .../provider/JSONRPCServiceBindingProvider.java | 124 ++ .../jsonrpc/provider/JSONRPCServiceServlet.java | 314 ++++ .../sca/binding/jsonrpc/provider/JavaToSmd.java | 56 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../sca/binding/jsonrpc/provider/jsonrpc.js | 493 ++++++ .../src/test/java/bean/TestBean.java | 51 + .../src/test/java/echo/Echo.java | 64 + .../src/test/java/echo/EchoBusinessException.java | 29 + .../src/test/java/echo/EchoClientImpl.java | 85 + .../src/test/java/echo/EchoComponentImpl.java | 103 ++ .../binding/jsonrpc/JSONRPCDataTypeTestCase.java | 203 +++ .../binding/jsonrpc/JSONRPCExceptionTestCase.java | 96 ++ .../binding/jsonrpc/JSONRPCReferenceTestCase.java | 72 + .../binding/jsonrpc/JSONRPCServiceTestCase.java | 80 + .../sca/binding/jsonrpc/JSONRPCSmdTestCase.java | 81 + .../src/test/resources/JSONRPCBinding.composite | 38 + .../src/test/resources/JSONRPCReference.composite | 33 + .../modules/binding-jsonrpc/LICENSE | 205 +++ .../modules/binding-jsonrpc/META-INF/MANIFEST.MF | 18 + .../sca-java-2.0-M4/modules/binding-jsonrpc/NOTICE | 6 + .../modules/binding-jsonrpc/pom.xml | 46 + .../sca/binding/jsonrpc/JSONRPCBinding.java | 33 + .../sca/binding/jsonrpc/JSONRPCBindingFactory.java | 35 + .../jsonrpc/impl/JSONRPCBindingFactoryImpl.java | 38 + .../binding/jsonrpc/impl/JSONRPCBindingImpl.java | 68 + ...scany.sca.binding.jsonrpc.JSONRPCBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../modules/binding-rmi-runtime/LICENSE | 205 +++ .../binding-rmi-runtime/META-INF/MANIFEST.MF | 32 + .../modules/binding-rmi-runtime/NOTICE | 6 + .../modules/binding-rmi-runtime/pom.xml | 79 + .../binding/rmi/provider/RMIBindingInvoker.java | 106 ++ .../rmi/provider/RMIBindingProviderFactory.java | 63 + .../rmi/provider/RMIReferenceBindingProvider.java | 80 + .../rmi/provider/RMIServiceBindingProvider.java | 169 ++ .../rmi/provider/RemoteInterfaceGenerator.java | 102 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../src/test/java/helloworld/HelloException.java | 60 + .../src/test/java/helloworld/HelloWorldImpl.java | 42 + .../test/java/helloworld/HelloWorldRmiImpl.java | 50 + .../test/java/helloworld/HelloWorldRmiService.java | 31 + .../test/java/helloworld/HelloWorldService.java | 31 + .../tuscany/sca/binding/rmi/BindingTestCase.java | 81 + .../test/resources/HelloWorldImpl.componentType | 23 + .../test/resources/HelloWorldRmiImpl.componentType | 28 + .../src/test/resources/RMIBindingTest.composite | 41 + .../sca-java-2.0-M4/modules/binding-rmi/LICENSE | 205 +++ .../modules/binding-rmi/META-INF/MANIFEST.MF | 18 + .../sca-java-2.0-M4/modules/binding-rmi/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-rmi/pom.xml | 41 + .../apache/tuscany/sca/binding/rmi/RMIBinding.java | 33 + .../tuscany/sca/binding/rmi/RMIBindingFactory.java | 33 + .../binding/rmi/impl/RMIBindingFactoryImpl.java | 35 + .../sca/binding/rmi/impl/RMIBindingImpl.java | 69 + ...pache.tuscany.sca.binding.rmi.RMIBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../modules/binding-sca-axis2-runtime/LICENSE | 205 +++ .../binding-sca-axis2-runtime/META-INF/MANIFEST.MF | 43 + .../modules/binding-sca-axis2-runtime/NOTICE | 6 + .../modules/binding-sca-axis2-runtime/pom.xml | 103 ++ .../axis2/impl/Axis2SCABindingProviderFactory.java | 57 + .../impl/Axis2SCAReferenceBindingProvider.java | 120 ++ .../axis2/impl/Axis2SCAServiceBindingProvider.java | 163 ++ ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../sca/binding/sca/axis2/AsynchTestCase.java | 80 + .../sca/binding/sca/axis2/CallbackTestCase.java | 84 + .../sca/binding/sca/axis2/PromotionTestCase.java | 74 + .../sca/binding/sca/axis2/SimpleTestCase.java | 110 ++ .../axis2/helloworld/HelloWorldCallbackRemote.java | 30 + .../sca/axis2/helloworld/HelloWorldClient.java | 27 + .../HelloWorldServiceCallbackOnewayRemote.java | 33 + .../HelloWorldServiceCallbackRemote.java | 31 + .../axis2/helloworld/HelloWorldServiceLocal.java | 27 + .../axis2/helloworld/HelloWorldServiceRemote.java | 29 + .../axis2/helloworld/HelloWorldServiceRemote2.java | 29 + .../HelloWorldClientCallbackOnewayRemoteImpl.java | 43 + .../impl/HelloWorldClientCallbackRemoteImpl.java | 42 + .../helloworld/impl/HelloWorldClientLocalImpl.java | 35 + .../impl/HelloWorldClientRemote2Impl.java | 35 + .../impl/HelloWorldClientRemoteImpl.java | 35 + .../HelloWorldServiceCallbackOnewayRemoteImpl.java | 35 + .../impl/HelloWorldServiceCallbackRemoteImpl.java | 39 + .../impl/HelloWorldServiceLocalImpl.java | 30 + .../HelloWorldServiceMultipleServicesImpl.java | 41 + .../impl/HelloWorldServiceRemoteImpl.java | 30 + .../resources/asynchReference/HelloWorld.composite | 36 + .../asynchReference/META-INF/sca-contribution.xml | 23 + .../resources/asynchService/HelloWorld.composite | 38 + .../asynchService/META-INF/sca-contribution.xml | 23 + .../callbackReference/HelloWorld.composite | 36 + .../META-INF/sca-contribution.xml | 24 + .../resources/callbackService/HelloWorld.composite | 43 + .../callbackService/META-INF/sca-contribution.xml | 24 + .../promotionReference/HelloWorld.composite | 33 + .../HelloWorldComponent.composite | 37 + .../META-INF/sca-contribution.xml | 23 + .../promotionService/HelloWorld.composite | 35 + .../promotionService/HelloWorldComponent.composite | 37 + .../promotionService/META-INF/sca-contribution.xml | 23 + .../resources/simpleReference/HelloWorld.composite | 67 + .../simpleReference/META-INF/sca-contribution.xml | 23 + .../resources/simpleService/HelloWorld.composite | 84 + .../simpleService/META-INF/sca-contribution.xml | 23 + .../modules/binding-sca-runtime/LICENSE | 205 +++ .../binding-sca-runtime/META-INF/MANIFEST.MF | 31 + .../modules/binding-sca-runtime/NOTICE | 6 + .../modules/binding-sca-runtime/pom.xml | 72 + .../binding/sca/provider/RemoteBindingHelper.java | 43 + .../sca/provider/RuntimeSCABindingProvider.java | 61 + .../provider/RuntimeSCABindingProviderFactory.java | 59 + .../RuntimeSCAReferenceBindingProvider.java | 240 +++ .../provider/RuntimeSCAServiceBindingProvider.java | 144 ++ .../binding/sca/provider/SCABindingInvoker.java | 72 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../apache/tuscany/sca/binding/sca/definitions.xml | 26 + .../sca/binding/sca/SCABindingTestCase.java | 103 ++ .../tuscany/sca/binding/sca/xml/ReadTestCase.java | 93 ++ .../tuscany/sca/binding/sca/xml/WriteTestCase.java | 88 ++ .../src/test/resources/Calculator.composite | 59 + .../resources/CalculatorServiceImpl.componentType | 33 + .../modules/binding-ws-axis2-policy/LICENSE | 205 +++ .../binding-ws-axis2-policy/META-INF/MANIFEST.MF | 59 + .../modules/binding-ws-axis2-policy/NOTICE | 6 + .../modules/binding-ws-axis2-policy/pom.xml | 139 ++ .../token/Axis2TokenAuthenticationPolicy.java | 54 + .../Axis2TokenAuthenticationPolicyProcessor.java | 113 ++ ...s2TokenAuthenticationPolicyProviderFactory.java | 59 + ...enAuthenticationReferencePolicyInterceptor.java | 90 ++ ...TokenAuthenticationReferencePolicyProvider.java | 71 + ...okenAuthenticationServicePolicyInterceptor.java | 97 ++ ...s2TokenAuthenticationServicePolicyProvider.java | 70 + .../configuration/Axis2ConfigParamPolicy.java | 53 + .../Axis2ConfigParamPolicyHandler.java | 78 + .../Axis2ConfigParamPolicyProcessor.java | 156 ++ .../Axis2ConfigParamPolicyProviderFactory.java | 81 + .../ws/axis2/policy/header/Axis2HeaderPolicy.java | 54 + .../policy/header/Axis2HeaderPolicyProcessor.java | 112 ++ .../header/Axis2HeaderPolicyProviderFactory.java | 59 + .../axis2/policy/header/Axis2HeaderPolicyUtil.java | 50 + .../Axis2HeaderReferencePolicyInterceptor.java | 76 + .../header/Axis2HeaderReferencePolicyProvider.java | 71 + .../Axis2HeaderServicePolicyInterceptor.java | 79 + .../header/Axis2HeaderServicePolicyProvider.java | 71 + .../ws/axis2/policy/header/Axis2SOAPHeader.java | 56 + .../axis2/policy/header/Axis2SOAPHeaderString.java | 54 + ...ca.contribution.processor.StAXArtifactProcessor | 21 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 20 + .../policy/configuration/PolicyReadTestCase.java | 60 + .../axis2/policy/configuration/mock_policies.xml | 36 + .../modules/binding-ws-axis2/LICENSE | 205 +++ .../modules/binding-ws-axis2/META-INF/MANIFEST.MF | 158 ++ .../modules/binding-ws-axis2/NOTICE | 6 + .../modules/binding-ws-axis2/pom.xml | 422 +++++ .../sca/binding/ws/axis2/Axis2BindingInvoker.java | 302 ++++ .../ws/axis2/Axis2BindingProviderFactory.java | 71 + .../binding/ws/axis2/Axis2ConfiguratorHelper.java | 78 + .../ws/axis2/Axis2OneWayBindingInvoker.java | 66 + .../ws/axis2/Axis2ReferenceBindingProvider.java | 86 + .../ws/axis2/Axis2ServiceBindingProvider.java | 84 + .../sca/binding/ws/axis2/Axis2ServiceClient.java | 461 ++++++ .../ws/axis2/Axis2ServiceInMessageReceiver.java | 62 + .../Axis2ServiceInOutSyncMessageReceiver.java | 99 ++ .../sca/binding/ws/axis2/Axis2ServiceProvider.java | 817 ++++++++++ .../sca/binding/ws/axis2/Axis2ServiceServlet.java | 356 +++++ .../sca/binding/ws/axis2/AxisPolicyHelper.java | 79 + .../binding/ws/axis2/TuscanyAxisConfigurator.java | 336 ++++ .../sca/binding/ws/axis2/TuscanyDispatcher.java | 104 ++ .../binding/ws/axis2/TuscanyListenerManager.java | 115 ++ .../sca/binding/ws/axis2/TuscanyListingAgent.java | 218 +++ ...xis2BindingBasicAuthenticationConfigurator.java | 111 ++ .../Axis2BindingHeaderConfigurator.java | 69 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../tuscany/sca/binding/ws/axis2/definitions.xml | 40 + .../sca/binding/ws/axis2/engine/config/axis2.xml | 504 ++++++ .../ws/axis2/engine/config/modules/modules.list | 1 + .../ws/axis2/engine/config/modules/rampart-1.4.mar | Bin 0 -> 2796 bytes .../ws/axis2/engine/config/services/services.list | 0 .../binding/ws/axis2/Axis2ReferenceTestCase.java | 83 + .../sca/binding/ws/axis2/Axis2ServiceTestCase.java | 104 ++ .../tuscany/sca/binding/ws/axis2/Greeter.java | 31 + .../sca/binding/ws/axis2/GreetingCallback.java | 24 + .../sca/binding/ws/axis2/itests/Account.java | 34 + .../binding/ws/axis2/itests/AccountService.java | 33 + .../tuscany/sca/binding/ws/axis2/itests/Bar.java | 58 + .../ws/axis2/itests/CustomerProfileData.java | 103 ++ .../tuscany/sca/binding/ws/axis2/itests/Echo.java | 29 + .../sca/binding/ws/axis2/itests/EchoComponent.java | 33 + .../sca/binding/ws/axis2/itests/EchoImpl.java | 29 + .../tuscany/sca/binding/ws/axis2/itests/Foo.java | 36 + .../sca/binding/ws/axis2/itests/HelloWorld.java | 29 + .../ws/axis2/itests/HelloWorldComponent.java | 33 + .../ws/axis2/itests/HelloWorldMultiService.java | 51 + .../ws/axis2/itests/HelloWorldNoWSDLTestCase.java | 83 + .../sca/binding/ws/axis2/itests/HelloWorldOM.java | 30 + .../sca/binding/ws/axis2/itests/HelloWorldOM2.java | 30 + .../ws/axis2/itests/HelloWorldOMComponent.java | 34 + .../ws/axis2/itests/HelloWorldOMService.java | 41 + .../ws/axis2/itests/HelloWorldOMTestCase.java | 64 + .../binding/ws/axis2/itests/HelloWorldService.java | 28 + .../ws/axis2/itests/HelloWorldTestCase.java | 52 + .../axis2/itests/HelloWorldWSDLMergedTestCase.java | 64 + .../itests/QuestionMarkWSDLImportTestCase.java | 104 ++ .../itests/QuestionMarkWSDLIncludeTestCase.java | 104 ++ .../ws/axis2/itests/QuestionMarkWSDLTestCase.java | 133 ++ .../ws/axis2/itests/UriPrecedenceTestCase.java | 74 + .../endpoints/AbstractHelloWorldOMTestCase.java | 70 + .../endpoints/DefaultMultiServiceTestCase.java | 24 + .../endpoints/DefaultSingleServiceTestCase.java | 24 + .../itests/endpoints/WSDLExplicitURITestCase.java | 24 + .../itests/endpoints/WSDLRelativeURITestCase.java | 24 + .../ws/axis2/itests/epr/HelloWorldTestCase.java | 53 + .../ws/axis2/itests/mtom/FileTransferClient.java | 36 + .../itests/mtom/FileTransferMTOMTestCaseOFF.java | 81 + .../ws/axis2/itests/mtom/FileTransferService.java | 32 + .../axis2/itests/mtom/FileTransferServiceImpl.java | 50 + .../sca/binding/ws/axis2/itests/pojo/Data.java | 53 + .../sca/binding/ws/axis2/itests/pojo/Data2.java | 35 + .../ws/axis2/itests/pojo/POJOWSTestCase.java | 50 + .../binding/ws/axis2/itests/pojo/TestService.java | 29 + .../ws/axis2/itests/pojo/TestServiceImpl.java | 59 + .../binding/ws/axis2/itests/pojo/package-info.java | 21 + .../AbstractHelloWorldOMTestCaseOFF.java | 70 + .../policy/configparams/ClientPWCBHandler.java | 45 + .../policy/configparams/IntegrityPWCBHandler.java | 45 + .../policy/configparams/ServerPWCBHandler.java | 45 + .../WSSecurityAuthenticationTestCaseFIXME.java | 24 + ...onfidentialityTestCaseFIXBouncyCastleIssue.java | 42 + .../WSSecurityIntegrityTestCaseOFF.java | 24 + .../mixed/AbstractHelloWorldOMTestCaseOFF.java | 73 + .../itests/policy/mixed/ClientPWCBHandler.java | 50 + .../itests/policy/mixed/IntegrityPWCBHandler.java | 50 + .../itests/policy/mixed/ServerPWCBHandler.java | 49 + .../policy/mixed/WSSecurityMixedTestCase.java | 27 + .../wspolicy/AbstractHelloWorldOMTestCaseOFF.java | 70 + .../itests/policy/wspolicy/ClientPWCBHandler.java | 45 + .../policy/wspolicy/IntegrityPWCBHandler.java | 45 + .../itests/policy/wspolicy/ServerPWCBHandler.java | 45 + .../WSSecurityAuthenticationTestCaseOFF.java | 27 + ...onfidentialityTestCaseFIXBouncyCastleIssue.java | 42 + .../wspolicy/WSSecurityIntegrityTestCaseOFF.java | 27 + .../itests/soap12/HelloWorldSOAP12TestCaseOFF.java | 63 + .../itests/soap12/QuestionMarkWSDLTestCaseOFF.java | 144 ++ ...rg.apache.tuscany.sca.policy.util.PolicyHandler | 20 + .../binding/ws/axis2/itests/HelloWorld.composite | 47 + .../ws/axis2/itests/HelloWorldNoWSDL.composite | 53 + .../sca/binding/ws/axis2/itests/customerdata.xsd | 36 + .../sca/binding/ws/axis2/itests/customerdefs.xsd | 27 + .../sca/binding/ws/axis2/itests/customerinfo.xsd | 31 + .../itests/endpoints/DefaultMultiService.composite | 53 + .../endpoints/DefaultSingleService.composite | 51 + .../itests/endpoints/WSDLExplicitURI.composite | 50 + .../itests/endpoints/WSDLRelativeURI.composite | 51 + .../endpoints/helloworld-om-relative-uri.wsdl | 78 + .../ws/axis2/itests/epr/HelloWorld.composite | 48 + .../ws/axis2/itests/helloworld-om-binding.wsdl | 45 + .../ws/axis2/itests/helloworld-om-merged.composite | 43 + .../ws/axis2/itests/helloworld-om-porttype.wsdl | 59 + .../binding/ws/axis2/itests/helloworld-om-uri.wsdl | 78 + .../ws/axis2/itests/helloworld-om.composite | 42 + .../sca/binding/ws/axis2/itests/helloworld-om.wsdl | 78 + .../ws/axis2/itests/helloworld-prec.composite | 46 + .../binding/ws/axis2/itests/helloworld-prec.wsdl | 81 + .../sca/binding/ws/axis2/itests/helloworld.wsdl | 86 + .../binding/ws/axis2/itests/mtom/filetransfer.wsdl | 84 + .../itests/mtom/filetransferservice.compositeOFF | 42 + .../binding/ws/axis2/itests/pojo/test.composite | 32 + .../WSSecurityAuthentication.composite.OFF | 51 + .../WSSecurityConfidentiality.composite.OFF | 50 + .../configparams/WSSecurityIntegrity.composite.OFF | 50 + .../itests/policy/configparams/definitions.xml | 101 ++ .../itests/policy/configparams/security.properties | 20 + .../itests/policy/configparams/tuscanyKeys.jks | Bin 0 -> 1379 bytes .../ws/axis2/itests/policy/intent/definitions.xml | 32 + .../policy/mixed/WSSecurityMixed.composite.OFF | 53 + .../ws/axis2/itests/policy/mixed/definitions.xml | 323 ++++ .../axis2/itests/policy/mixed/security.properties | 20 + .../ws/axis2/itests/policy/mixed/tuscanyKeys.jks | Bin 0 -> 1379 bytes .../WSSecurityAuthentication.composite.OFF | 51 + .../WSSecurityConfidentiality.composite.OFF | 50 + .../wspolicy/WSSecurityIntegrity.composite.OFF | 51 + .../axis2/itests/policy/wspolicy/definitions.xml | 203 +++ .../axis2/itests/policy/wspolicy/tuscanyKeys.jks | Bin 0 -> 1379 bytes .../axis2/itests/questionmark-import-nested.wsdl | 70 + .../ws/axis2/itests/questionmark-import.wsdl | 49 + .../ws/axis2/itests/questionmark-include.wsdl | 94 ++ .../itests/questionmark-wsdl-import.composite | 31 + .../itests/questionmark-wsdl-include.composite | 31 + .../ws/axis2/itests/questionmark-wsdl.composite | 33 + .../itests/soap12/HelloWorldSOAP12.composite.OFF | 72 + .../itests/soap12/questionmark-wsdl.composite.OFF | 41 + .../modules/binding-ws-wsdlgen/LICENSE | 205 +++ .../binding-ws-wsdlgen/META-INF/MANIFEST.MF | 62 + .../modules/binding-ws-wsdlgen/NOTICE | 6 + .../modules/binding-ws-wsdlgen/pom.xml | 84 + .../binding/ws/wsdlgen/BindingWSDLGenerator.java | 342 ++++ .../ws/wsdlgen/Interface2WSDLGenerator.java | 887 +++++++++++ .../ws/wsdlgen/WSDLDefinitionGenerator.java | 305 ++++ .../ws/wsdlgen/WSDLGenerationException.java | 54 + .../binding/ws/wsdlgen/WSDLServiceGenerator.java | 512 ++++++ .../ws/wsdlgen/WebServiceBindingBuilder.java | 55 + ...che.tuscany.sca.assembly.builder.BindingBuilder | 17 + .../wsdlgen-validation-messages.properties | 32 + .../apache/tuscany/sca/binding/ws/other/Other.java | 34 + .../tuscany/sca/binding/ws/other/package-info.java | 21 + .../ws/wsdlgen/BindingWSDLGeneratorTestCase.java | 86 + .../wsdlgen/Interface2WSDLGeneratorTestCase.java | 75 + .../sca/binding/ws/wsdlgen/TestException.java | 47 + .../tuscany/sca/binding/ws/wsdlgen/TestFault.java | 46 + .../sca/binding/ws/wsdlgen/TestFaultBean.java | 54 + .../sca/binding/ws/wsdlgen/TestJavaClass.java | 32 + .../sca/binding/ws/wsdlgen/TestJavaInterface.java | 67 + .../sca-java-2.0-M4/modules/binding-ws/LICENSE | 205 +++ .../modules/binding-ws/META-INF/MANIFEST.MF | 43 + branches/sca-java-2.0-M4/modules/binding-ws/NOTICE | 6 + .../sca-java-2.0-M4/modules/binding-ws/pom.xml | 95 ++ .../tuscany/sca/binding/ws/WebServiceBinding.java | 214 +++ .../sca/binding/ws/WebServiceBindingFactory.java | 35 + .../binding/ws/addressing/EndPointReference.java | 62 + .../ws/impl/WebServiceBindingFactoryImpl.java | 35 + .../sca/binding/ws/impl/WebServiceBindingImpl.java | 299 ++++ .../binding/ws/xml/EndPointReferenceHelper.java | 223 +++ .../binding/ws/xml/WebServiceBindingProcessor.java | 382 +++++ .../sca/binding/ws/xml/WebServiceConstants.java | 47 + ...tuscany.sca.binding.ws.WebServiceBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../binding-wsxml-validation-messages.properties | 28 + .../tuscany/sca/binding/ws/xml/ReadTestCase.java | 106 ++ .../tuscany/sca/binding/ws/xml/WriteTestCase.java | 82 + .../ws/xml/Calculator-bad-wsdlElement.composite | 59 + .../sca/binding/ws/xml/Calculator.composite | 63 + .../binding/ws/xml/CalculatorImpl.componentType | 45 + .../binding/ws/xml/PoliciedCalculator.composite | 60 + .../apache/tuscany/sca/binding/ws/xml/example.wsdl | 26 + .../sca/binding/ws/xml/invalid-stockquote.wsdl | 58 + .../org/apache/tuscany/sca/binding/ws/xml/ipo.xsd | 136 ++ .../tuscany/sca/binding/ws/xml/stockquote.wsdl | 58 + .../apache/tuscany/sca/binding/ws/xml/test1.wsdl | 45 + .../apache/tuscany/sca/binding/ws/xml/test1.xsd | 33 + .../apache/tuscany/sca/binding/ws/xml/test2.wsdl | 63 + .../sca/binding/ws/xml/unwrapped-stockquote.wsdl | 76 + .../modules/builder/META-INF/MANIFEST.MF | 30 + branches/sca-java-2.0-M4/modules/builder/pom.xml | 55 + .../tuscany/sca/builder/impl/BaseBuilderImpl.java | 703 ++++++++ .../sca/builder/impl/BindingURIBuilderImpl.java | 379 +++++ .../sca/builder/impl/ComponentBuilderImpl.java | 1244 +++++++++++++++ .../impl/ComponentReferenceBindingBuilderImpl.java | 81 + .../ComponentReferencePromotionBuilderImpl.java | 173 ++ .../impl/ComponentServiceBindingBuilderImpl.java | 80 + .../builder/impl/CompositeCloneBuilderImpl.java | 100 ++ .../impl/CompositeComponentTypeBuilderImpl.java | 528 +++++++ .../builder/impl/CompositeIncludeBuilderImpl.java | 126 ++ .../builder/impl/CompositePolicyBuilderImpl.java | 534 +++++++ .../sca/builder/impl/EndpointBuilderImpl.java | 147 ++ .../builder/impl/EndpointReferenceBuilderImpl.java | 839 ++++++++++ .../tuscany/sca/builder/impl/ModelBuilderImpl.java | 184 +++ .../builder/impl/PolicyAttachmentBuilderImpl.java | 379 +++++ .../builder/impl/ReferenceConfigurationUtil.java | 216 +++ .../sca/builder/impl/ServiceConfigurationUtil.java | 88 ++ .../sca/builder/impl/StructuralURIBuilderImpl.java | 276 ++++ ...e.tuscany.sca.assembly.builder.CompositeBuilder | 17 + .../sca/builder/impl/BuildPolicyTestCase.java | 134 ++ .../sca/builder/impl/CompositeBuilderTestCase.java | 139 ++ .../tuscany/sca/builder/impl/MockPolicy.java | 39 + .../sca/builder/impl/PolicyAttachmentTestCase.java | 151 ++ .../sca/builder/impl/TestPolicyProcessor.java | 58 + .../tuscany/sca/builder/impl/Calculator.composite | 49 + .../tuscany/sca/builder/impl/Composite1.composite | 34 + .../tuscany/sca/builder/impl/Composite2.composite | 33 + .../tuscany/sca/builder/impl/Composite3.composite | 29 + .../tuscany/sca/builder/impl/Composite4.composite | 32 + .../tuscany/sca/builder/impl/definitions.xml | 38 + .../apache/tuscany/sca/builder/impl/scenario.odg | Bin 0 -> 15518 bytes .../apache/tuscany/sca/builder/impl/scenario.png | Bin 0 -> 4041817 bytes .../tuscany/sca/builder/impl/test_definitions.xml | 207 +++ .../modules/common-java/META-INF/MANIFEST.MF | 24 + .../sca-java-2.0-M4/modules/common-java/pom.xml | 55 + .../java/classloader/ClassLoaderDelegate.java | 97 ++ .../sca/common/java/collection/CollectionMap.java | 62 + .../java/collection/CompoundEnumeration.java | 93 ++ .../common/java/collection/CompoundIterator.java | 113 ++ .../sca/common/java/collection/LRUCache.java | 88 ++ .../tuscany/sca/common/java/io/IOHelper.java | 149 ++ .../java/reflection/JavaIntrospectionHelper.java | 586 +++++++ .../JavaIntrospectionHelperTestCase.java | 71 + .../sca/common/java/reflection/SubTestImpl.java | 45 + .../tuscany/sca/common/java/reflection/Test1.java | 28 + .../tuscany/sca/common/java/reflection/Test2.java | 28 + .../sca/common/java/reflection/TestImpl.java | 44 + .../modules/common-xml/META-INF/MANIFEST.MF | 58 + .../sca-java-2.0-M4/modules/common-xml/pom.xml | 98 ++ .../tuscany/sca/common/xml/XMLDocumentHelper.java | 152 ++ .../tuscany/sca/common/xml/dom/DOMHelper.java | 230 +++ .../sca/common/xml/dom/impl/SAX2DOMAdapter.java | 244 +++ .../tuscany/sca/common/xml/sax/SAXHelper.java | 79 + .../tuscany/sca/common/xml/stax/StAXHelper.java | 498 ++++++ .../sca/common/xml/stax/impl/StAX2SAXAdapter.java | 256 +++ .../common/xml/stax/impl/XMLStreamSerializer.java | 368 +++++ .../common/xml/stax/reader/DOMXMLStreamReader.java | 36 + .../sca/common/xml/stax/reader/DOMXmlNodeImpl.java | 150 ++ .../stax/reader/DelegatingNamespaceContext.java | 310 ++++ .../stax/reader/NameValueArrayStreamReader.java | 404 +++++ .../xml/stax/reader/NameValuePairStreamReader.java | 348 ++++ .../sca/common/xml/stax/reader/NamedProperty.java | 59 + .../xml/stax/reader/NamespaceContextImpl.java | 124 ++ .../xml/stax/reader/NilElementStreamReader.java | 279 ++++ .../common/xml/stax/reader/SimpleXmlNodeImpl.java | 112 ++ .../xml/stax/reader/WrappingXMLStreamReader.java | 100 ++ .../xml/stax/reader/XMLDocumentStreamReader.java | 482 ++++++ .../xml/stax/reader/XMLFragmentStreamReader.java | 53 + .../stax/reader/XMLFragmentStreamReaderImpl.java | 858 ++++++++++ .../sca/common/xml/stax/reader/XMLStreamable.java | 37 + .../sca/common/xml/stax/reader/XmlNode.java | 69 + .../common/xml/stax/reader/XmlNodeIterator.java | 258 +++ .../xml/stax/reader/XmlTreeStreamReaderImpl.java | 531 +++++++ .../sca/common/xml/xpath/XMLCharHelper.java | 613 +++++++ .../tuscany/sca/common/xml/xpath/XPathHelper.java | 151 ++ .../sca/common/xml/dom/DOMHelperTestCase.java | 81 + .../sca/common/xml/stax/StAXHelperTestCase.java | 112 ++ .../stax/reader/XmlTreeStreamReaderTestCase.java | 207 +++ .../sca/common/xml/xpath/XPathHelperTestCase.java | 120 ++ .../apache/tuscany/sca/common/xml/stax/test.wsdl | 60 + .../apache/tuscany/sca/common/xml/stax/test.xsd | 30 + .../modules/contribution-osgi/LICENSE | 205 +++ .../modules/contribution-osgi/META-INF/MANIFEST.MF | 23 + .../modules/contribution-osgi/NOTICE | 6 + .../modules/contribution-osgi/pom.xml | 72 + .../sca/contribution/osgi/BundleReference.java | 136 ++ .../osgi/impl/OSGiBundleActivator.java | 152 ++ .../osgi/impl/OSGiBundleContributionScanner.java | 200 +++ .../osgi/impl/OSGiBundleProcessor.java | 75 + .../impl/OSGiBundleReferenceModelResolver.java | 117 ++ .../osgi/impl/OSGiClassReferenceModelResolver.java | 73 + ...tuscany.sca.contribution.resolver.ModelResolver | 18 + ...ny.sca.contribution.scanner.ContributionScanner | 18 + .../sca-java-2.0-M4/modules/contribution/LICENSE | 205 +++ .../modules/contribution/META-INF/MANIFEST.MF | 61 + .../sca-java-2.0-M4/modules/contribution/NOTICE | 6 + .../sca-java-2.0-M4/modules/contribution/pom.xml | 63 + .../apache/tuscany/sca/contribution/Artifact.java | 74 + .../tuscany/sca/contribution/ContentType.java | 40 + .../tuscany/sca/contribution/Contribution.java | 125 ++ .../sca/contribution/ContributionFactory.java | 65 + .../sca/contribution/ContributionMetadata.java | 56 + .../contribution/DefaultContributionFactory.java | 32 + .../tuscany/sca/contribution/DefaultExport.java | 30 + .../tuscany/sca/contribution/DefaultImport.java | 30 + .../apache/tuscany/sca/contribution/Export.java | 48 + .../apache/tuscany/sca/contribution/Import.java | 57 + .../tuscany/sca/contribution/PackageType.java | 57 + .../sca/contribution/impl/ArtifactImpl.java | 94 ++ .../contribution/impl/ContributionFactoryImpl.java | 60 + .../sca/contribution/impl/ContributionImpl.java | 167 ++ .../impl/ContributionMetadataImpl.java | 65 + .../sca/contribution/impl/DefaultExportImpl.java | 46 + .../sca/contribution/impl/DefaultImportImpl.java | 56 + .../java/DefaultJavaImportExportFactory.java | 30 + .../tuscany/sca/contribution/java/JavaExport.java | 43 + .../tuscany/sca/contribution/java/JavaImport.java | 58 + .../contribution/java/JavaImportExportFactory.java | 42 + .../java/impl/ClassLoaderModelResolver.java | 173 ++ .../java/impl/ContributionClassLoader.java | 386 +++++ .../contribution/java/impl/ContributionHelper.java | 96 ++ .../sca/contribution/java/impl/JavaExportImpl.java | 59 + .../java/impl/JavaExportModelResolver.java | 77 + .../java/impl/JavaExportProcessor.java | 147 ++ .../java/impl/JavaImportExportFactoryImpl.java | 41 + .../sca/contribution/java/impl/JavaImportImpl.java | 111 ++ .../java/impl/JavaImportModelResolver.java | 63 + .../java/impl/JavaImportProcessor.java | 152 ++ .../DefaultNamespaceImportExportFactory.java | 30 + .../contribution/namespace/NamespaceExport.java | 46 + .../contribution/namespace/NamespaceImport.java | 59 + .../namespace/NamespaceImportExportFactory.java | 42 + .../namespace/impl/NamespaceExportImpl.java | 55 + .../impl/NamespaceExportModelResolver.java | 55 + .../namespace/impl/NamespaceExportProcessor.java | 165 ++ .../impl/NamespaceImportExportFactoryImpl.java | 41 + .../namespace/impl/NamespaceImportImpl.java | 93 ++ .../namespace/impl/NamespaceImportProcessor.java | 169 ++ .../contribution/processor/ArtifactProcessor.java | 48 + .../processor/BaseStAXArtifactProcessor.java | 492 ++++++ .../processor/ContributionException.java | 45 + .../processor/ContributionReadException.java | 95 ++ .../processor/ContributionResolveException.java | 42 + .../processor/ContributionRuntimeException.java | 44 + .../processor/ContributionWriteException.java | 62 + .../DefaultArtifactProcessorExtensionPoint.java | 66 + ...DefaultStAXArtifactProcessorExtensionPoint.java | 328 ++++ ...efaultStAXAttributeProcessorExtensionPoint.java | 293 ++++ .../DefaultURLArtifactProcessorExtensionPoint.java | 323 ++++ .../DefaultValidatingXMLInputFactory.java | 405 +++++ .../DefaultValidationSchemaExtensionPoint.java | 110 ++ .../processor/ExtendedArtifactProcessor.java | 41 + .../processor/ExtendedURLArtifactProcessor.java | 30 + .../processor/ExtensibleStAXArtifactProcessor.java | 287 ++++ .../ExtensibleStAXAttributeProcessor.java | 259 +++ .../processor/ExtensibleURLArtifactProcessor.java | 145 ++ .../contribution/processor/ProcessorContext.java | 94 ++ .../processor/StAXArtifactProcessor.java | 61 + .../StAXArtifactProcessorExtensionPoint.java | 56 + .../processor/StAXAttributeProcessor.java | 63 + .../StAXAttributeProcessorExtensionPoint.java | 56 + .../processor/URLArtifactProcessor.java | 51 + .../URLArtifactProcessorExtensionPoint.java | 65 + .../processor/UnrecognizedElementException.java | 48 + .../processor/UnsupportedContentTypeException.java | 43 + .../processor/UnsupportedPackageTypeException.java | 40 + .../processor/ValidatingXMLInputFactory.java | 47 + .../processor/ValidatingXMLStreamReader.java | 406 +++++ .../processor/ValidationSchemaExtensionPoint.java | 63 + .../impl/ContributionContentProcessor.java | 285 ++++ .../processor/xml/AnyAttributeProcessor.java | 79 + .../processor/xml/AnyElementProcessor.java | 96 ++ .../sca/contribution/resolver/ClassReference.java | 107 ++ .../resolver/DefaultDelegatingModelResolver.java | 69 + .../resolver/DefaultImportAllModelResolver.java | 81 + .../resolver/DefaultImportModelResolver.java | 70 + .../resolver/DefaultModelResolver.java | 89 ++ .../DefaultModelResolverExtensionPoint.java | 123 ++ .../resolver/ExtensibleModelResolver.java | 179 +++ .../sca/contribution/resolver/ModelResolver.java | 74 + .../resolver/ModelResolverExtensionPoint.java | 52 + .../contribution/resolver/ResolverExtension.java | 45 + .../contribution/resolver/ResourceReference.java | 103 ++ .../contribution/scanner/ContributionScanner.java | 67 + .../scanner/ContributionScannerExtensionPoint.java | 50 + .../DefaultContributionScannerExtensionPoint.java | 126 ++ .../scanner/impl/DirectoryContributionScanner.java | 117 ++ .../scanner/impl/JarContributionScanner.java | 126 ++ ...ributionGeneratedMetadataDocumentProcessor.java | 48 + .../xml/ContributionMetadataDocumentProcessor.java | 127 ++ .../xml/ContributionMetadataProcessor.java | 245 +++ .../xml/ContributionModelResolver.java | 73 + ...he.tuscany.sca.contribution.ContributionFactory | 18 + ...y.sca.contribution.java.JavaImportExportFactory | 18 + ...ribution.namespace.NamespaceImportExportFactory | 18 + ...ca.contribution.processor.StAXArtifactProcessor | 24 + ...n.processor.StAXArtifactProcessorExtensionPoint | 18 + ...a.contribution.processor.StAXAttributeProcessor | 19 + ....processor.StAXAttributeProcessorExtensionPoint | 18 + ...sca.contribution.processor.URLArtifactProcessor | 21 + ...on.processor.URLArtifactProcessorExtensionPoint | 18 + ...ontribution.processor.ValidatingXMLInputFactory | 17 + ...bution.processor.ValidationSchemaExtensionPoint | 18 + ...tuscany.sca.contribution.resolver.ModelResolver | 19 + ...ntribution.resolver.ModelResolverExtensionPoint | 18 + ...ution.scanner.ContributionScannerExtensionPoint | 18 + ...ontribution-java-validation-messages.properties | 23 + ...bution-namespace-validation-messages.properties | 23 + .../contribution-validation-messages.properties | 34 + ...contribution-xml-validation-messages.properties | 24 + .../java/impl/ContributionClassLoaderTestCase.java | 262 +++ .../java/impl/JavaExportProcessorTestCase.java | 103 ++ .../java/impl/JavaImportProcessorTestCase.java | 106 ++ .../impl/NamespaceExportProcessorTestCase.java | 106 ++ .../impl/NamespaceImportProcessorTestCase.java | 110 ++ ...URLartifactProcessorExtensionPointTestCase.java | 116 ++ .../resolver/DefaultModelResolverTestCase.java | 94 ++ .../resolver/ExtensibleModelResolverTestCase.java | 136 ++ .../contribution/resolver/TestModelResolver.java | 59 + .../xml/ContributionMetadataProcessorTestCase.java | 142 ++ .../resources/deployables/sample-calculator.jar | Bin 0 -> 26901 bytes .../resources/repository/sample-calculator.jar | Bin 0 -> 29164 bytes .../contribution/src/test/resources/test.composite | 22 + .../contribution/src/test/resources/test.ext | 0 .../modules/core-databinding/LICENSE | 205 +++ .../modules/core-databinding/META-INF/MANIFEST.MF | 46 + .../modules/core-databinding/NOTICE | 6 + .../modules/core-databinding/pom.xml | 90 ++ .../DataBindingJavaInterfaceProcessor.java | 131 ++ .../processor/WrapperJavaInterfaceProcessor.java | 126 ++ .../transformers/Array2ArrayTransformer.java | 104 ++ .../Exception2ExceptionTransformer.java | 112 ++ .../transformers/Input2InputTransformer.java | 270 ++++ .../transformers/Output2OutputTransformer.java | 251 +++ .../wire/DataBindingRuntimeWireProcessor.java | 188 +++ .../wire/DataTransformationInterceptor.java | 109 ++ .../databinding/wire/PassByValueInterceptor.java | 81 + ....apache.tuscany.sca.databinding.PullTransformer | 29 + ...terfacedef.java.introspect.JavaInterfaceVisitor | 19 + ...apache.tuscany.sca.runtime.RuntimeWireProcessor | 17 + branches/sca-java-2.0-M4/modules/core-spi/LICENSE | 205 +++ .../modules/core-spi/META-INF/MANIFEST.MF | 50 + branches/sca-java-2.0-M4/modules/core-spi/NOTICE | 6 + branches/sca-java-2.0-M4/modules/core-spi/pom.xml | 71 + .../modules/core-spi/src/doc/Context Model.emx | 673 ++++++++ .../sca/context/ComponentContextFactory.java | 37 + .../tuscany/sca/context/CompositeContext.java | 91 ++ .../sca/context/ContextFactoryExtensionPoint.java | 50 + .../DefaultContextFactoryExtensionPoint.java | 116 ++ .../tuscany/sca/context/PropertyValueFactory.java | 40 + .../tuscany/sca/context/RequestContextFactory.java | 34 + .../tuscany/sca/context/ThreadMessageContext.java | 57 + .../sca/invocation/DataExchangeSemantics.java | 34 + .../apache/tuscany/sca/invocation/Interceptor.java | 40 + .../tuscany/sca/invocation/InvocationChain.java | 100 ++ .../org/apache/tuscany/sca/invocation/Invoker.java | 36 + .../org/apache/tuscany/sca/invocation/Message.java | 127 ++ .../tuscany/sca/invocation/MessageFactory.java | 36 + .../org/apache/tuscany/sca/invocation/Phase.java | 69 + .../tuscany/sca/invocation/PhasedInterceptor.java | 31 + .../tuscany/sca/management/ConfigAttributes.java | 26 + .../tuscany/sca/management/ManagementService.java | 39 + .../tuscany/sca/provider/BasePolicyProvider.java | 169 ++ .../sca/provider/BindingProviderFactory.java | 50 + .../DefaultProviderFactoryExtensionPoint.java | 498 ++++++ .../sca/provider/ImplementationProvider.java | 68 + .../provider/ImplementationProviderFactory.java | 42 + .../sca/provider/OperationSelectorProvider.java | 39 + .../provider/OperationSelectorProviderFactory.java | 53 + .../tuscany/sca/provider/PolicyImplementor.java | 38 + .../tuscany/sca/provider/PolicyProvider.java | 45 + .../sca/provider/PolicyProviderFactory.java | 51 + .../tuscany/sca/provider/PolicyProviderRRB.java | 37 + .../tuscany/sca/provider/ProviderFactory.java | 36 + .../provider/ProviderFactoryExtensionPoint.java | 63 + .../sca/provider/ReferenceBindingProvider.java | 76 + .../sca/provider/ReferenceBindingProviderRRB.java | 35 + .../sca/provider/ServiceBindingProvider.java | 63 + .../sca/provider/ServiceBindingProviderRRB.java | 35 + .../tuscany/sca/provider/WireFormatProvider.java | 54 + .../sca/provider/WireFormatProviderFactory.java | 53 + .../tuscany/sca/runtime/ActivationException.java | 37 + .../tuscany/sca/runtime/CompositeActivator.java | 107 ++ .../DefaultWireProcessorExtensionPoint.java | 127 ++ .../tuscany/sca/runtime/DomainRegistryFactory.java | 46 + .../tuscany/sca/runtime/EndpointListener.java | 46 + .../sca/runtime/EndpointReferenceBinder.java | 42 + .../tuscany/sca/runtime/EndpointRegistry.java | 48 + .../tuscany/sca/runtime/EndpointSerializer.java | 38 + .../tuscany/sca/runtime/ReferenceParameters.java | 59 + .../tuscany/sca/runtime/RuntimeComponent.java | 83 + .../sca/runtime/RuntimeComponentContext.java | 87 + .../sca/runtime/RuntimeComponentReference.java | 108 ++ .../sca/runtime/RuntimeComponentService.java | 138 ++ .../tuscany/sca/runtime/RuntimeEndpoint.java | 104 ++ .../sca/runtime/RuntimeEndpointReference.java | 104 ++ .../apache/tuscany/sca/runtime/RuntimeWire.java | 114 ++ .../tuscany/sca/runtime/RuntimeWireProcessor.java | 35 + .../RuntimeWireProcessorExtensionPoint.java | 53 + .../tuscany/sca/work/NotificationListener.java | 67 + .../org/apache/tuscany/sca/work/WorkScheduler.java | 53 + .../tuscany/sca/work/WorkSchedulerException.java | 59 + ...uscany.sca.context.ContextFactoryExtensionPoint | 18 + ...tresolver.EndpointResolverFactoryExtensionPoint | 18 + ...cany.sca.provider.ProviderFactoryExtensionPoint | 18 + ....sca.runtime.RuntimeWireProcessorExtensionPoint | 18 + ...efaultContextFactoryExtensionPointTestCase.java | 207 +++ branches/sca-java-2.0-M4/modules/core/LICENSE | 205 +++ .../modules/core/META-INF/MANIFEST.MF | 67 + branches/sca-java-2.0-M4/modules/core/NOTICE | 6 + branches/sca-java-2.0-M4/modules/core/pom.xml | 89 ++ .../sca/core/assembly/RuntimeAssemblyFactory.java | 74 + .../core/assembly/impl/CompositeActivatorImpl.java | 846 ++++++++++ .../core/assembly/impl/EndpointRegistryImpl.java | 208 +++ .../core/assembly/impl/EndpointSerializerImpl.java | 111 ++ .../assembly/impl/ReferenceParameterProcessor.java | 98 ++ .../assembly/impl/ReferenceParametersImpl.java | 121 ++ .../core/assembly/impl/RuntimeComponentImpl.java | 111 ++ .../impl/RuntimeComponentReferenceImpl.java | 150 ++ .../assembly/impl/RuntimeComponentServiceImpl.java | 169 ++ .../core/assembly/impl/RuntimeEndpointImpl.java | 101 ++ .../impl/RuntimeEndpointReferenceImpl.java | 100 ++ .../sca/core/assembly/impl/RuntimeWireImpl.java | 783 +++++++++ .../context/DefaultComponentContextFactory.java | 43 + .../core/context/DefaultRequestContextFactory.java | 40 + .../sca/core/context/ServiceReferenceExt.java | 60 + .../context/impl/CallbackServiceReferenceImpl.java | 154 ++ .../core/context/impl/ComponentContextImpl.java | 496 ++++++ .../sca/core/context/impl/RequestContextImpl.java | 118 ++ .../core/context/impl/ServiceReferenceImpl.java | 481 ++++++ .../tuscany/sca/core/factory/InstanceWrapper.java | 48 + .../sca/core/factory/ObjectCreationException.java | 47 + .../tuscany/sca/core/factory/ObjectFactory.java | 35 + .../invocation/CallableReferenceObjectFactory.java | 63 + .../invocation/CallbackInterfaceInterceptor.java | 60 + .../invocation/CallbackReferenceObjectFactory.java | 50 + .../core/invocation/CallbackWireObjectFactory.java | 47 + .../sca/core/invocation/CglibProxyFactory.java | 149 ++ .../DefaultProxyFactoryExtensionPoint.java | 95 ++ .../core/invocation/ExtensibleProxyFactory.java | 114 ++ .../core/invocation/ExtensibleWireProcessor.java | 44 + .../core/invocation/NonBlockingInterceptor.java | 202 +++ .../core/invocation/ProxyCreationException.java | 48 + .../tuscany/sca/core/invocation/ProxyFactory.java | 88 ++ .../invocation/ProxyFactoryExtensionPoint.java | 53 + .../sca/core/invocation/RuntimeWireInvoker.java | 268 ++++ .../sca/core/invocation/WireObjectFactory.java | 55 + .../invocation/impl/AsyncJDKInvocationHandler.java | 93 ++ .../sca/core/invocation/impl/AsyncResponse.java | 68 + .../core/invocation/impl/InvocationChainImpl.java | 195 +++ .../impl/JDKCallbackInvocationHandler.java | 80 + .../core/invocation/impl/JDKInvocationHandler.java | 537 +++++++ .../sca/core/invocation/impl/JDKProxyFactory.java | 177 +++ .../core/invocation/impl/MessageFactoryImpl.java | 36 + .../sca/core/invocation/impl/MessageImpl.java | 117 ++ .../impl/NoMethodForOperationException.java | 45 + .../sca/core/invocation/impl/PhaseManager.java | 299 ++++ .../sca/core/invocation/impl/PhaseSorter.java | 236 +++ .../core/runtime/DefaultDomainRegistryFactory.java | 157 ++ .../runtime/impl/EndpointReferenceBinderImpl.java | 299 ++++ .../sca/core/scope/AbstractScopeContainer.java | 196 +++ .../sca/core/scope/DefaultScopeRegistry.java | 40 + .../org/apache/tuscany/sca/core/scope/Scope.java | 62 + .../tuscany/sca/core/scope/ScopeContainer.java | 158 ++ .../sca/core/scope/ScopeContainerFactory.java | 32 + .../tuscany/sca/core/scope/ScopeRegistry.java | 43 + .../core/scope/ScopedImplementationProvider.java | 65 + .../sca/core/scope/ScopedRuntimeComponent.java | 40 + .../sca/core/scope/TargetDestructionException.java | 44 + .../core/scope/TargetInitializationException.java | 44 + .../sca/core/scope/TargetNotFoundException.java | 44 + .../sca/core/scope/TargetResolutionException.java | 44 + .../core/scope/impl/CompositeScopeContainer.java | 87 + .../scope/impl/CompositeScopeContainerFactory.java | 40 + .../sca/core/scope/impl/ScopeRegistryImpl.java | 70 + .../core/scope/impl/StatelessScopeContainer.java | 61 + .../scope/impl/StatelessScopeContainerFactory.java | 40 + .../sca/core/work/impl/DefaultWorkScheduler.java | 195 +++ .../sca/core/work/impl/ThreadPoolWorkManager.java | 228 +++ .../apache/tuscany/sca/core/work/impl/Work.java | 65 + .../tuscany/sca/core/work/impl/WorkEvent.java | 80 + .../tuscany/sca/core/work/impl/WorkItem.java | 167 ++ .../tuscany/sca/core/work/impl/WorkListener.java | 32 + ...org.apache.tuscany.sca.assembly.AssemblyFactory | 18 + ...che.tuscany.sca.context.ComponentContextFactory | 17 + ...pache.tuscany.sca.context.RequestContextFactory | 17 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ....sca.core.invocation.ProxyFactoryExtensionPoint | 18 + ...org.apache.tuscany.sca.core.scope.ScopeRegistry | 18 + ...rg.apache.tuscany.sca.invocation.MessageFactory | 18 + ...g.apache.tuscany.sca.runtime.CompositeActivator | 18 + ...pache.tuscany.sca.runtime.DomainRegistryFactory | 17 + ...che.tuscany.sca.runtime.EndpointReferenceBinder | 17 + ...org.apache.tuscany.sca.runtime.EndpointRegistry | 18 + ...g.apache.tuscany.sca.runtime.EndpointSerializer | 17 + .../org.apache.tuscany.sca.work.WorkScheduler | 18 + .../endpoint-validation-messages.properties | 22 + .../impl/InvocationChainImplTestCase.java | 92 ++ .../core/invocation/impl/PhaseManagerTestCase.java | 50 + .../core/invocation/impl/PhaseSorterTestCase.java | 67 + .../tuscany/sca/core/work/impl/FailingWork.java | 54 + .../core/work/impl/JSR237MyFailingRunnable.java | 43 + .../sca/core/work/impl/JSR237MyRunnable.java | 71 + .../sca/core/work/impl/JSR237MyRunnerListener.java | 154 ++ .../work/impl/Jsr237WorkSchedulerTestCase.java | 240 +++ .../sca/core/work/impl/TestWorkListener.java | 153 ++ .../work/impl/ThreadPoolWorkManagerTestCase.java | 227 +++ .../tuscany/sca/core/work/impl/TimeDelayWork.java | 86 + .../apache/tuscany/sca/scope/ScopeTestCase.java | 66 + .../org.apache.tuscany.sca.invocation.PhaseTest | 24 + branches/sca-java-2.0-M4/modules/data-api/LICENSE | 205 +++ .../modules/data-api/META-INF/MANIFEST.MF | 16 + branches/sca-java-2.0-M4/modules/data-api/NOTICE | 6 + branches/sca-java-2.0-M4/modules/data-api/pom.xml | 38 + .../tuscany/sca/data/collection/Collection.java | 78 + .../apache/tuscany/sca/data/collection/Entry.java | 85 + .../apache/tuscany/sca/data/collection/Item.java | 159 ++ .../sca/data/collection/ItemCollection.java | 30 + .../sca/data/collection/LocalItemCollection.java | 28 + .../sca/data/collection/NotFoundException.java | 45 + .../modules/databinding-axiom/LICENSE | 205 +++ .../modules/databinding-axiom/META-INF/MANIFEST.MF | 31 + .../modules/databinding-axiom/NOTICE | 6 + .../modules/databinding-axiom/pom.xml | 112 ++ .../sca/databinding/axiom/AxiomDataBinding.java | 62 + .../tuscany/sca/databinding/axiom/AxiomHelper.java | 142 ++ .../sca/databinding/axiom/Exception2OMElement.java | 95 ++ .../axiom/Externalizable2OMElement.java | 77 + .../sca/databinding/axiom/OMElement2Exception.java | 79 + .../axiom/OMElement2Externalizable.java | 69 + .../sca/databinding/axiom/OMElement2Object.java | 50 + .../sca/databinding/axiom/OMElement2String.java | 64 + .../axiom/OMElement2XMLStreamReader.java | 66 + .../databinding/axiom/OMElementWrapperHandler.java | 251 +++ .../sca/databinding/axiom/Object2OMElement.java | 63 + .../sca/databinding/axiom/String2OMElement.java | 64 + .../axiom/XMLStreamReader2OMElement.java | 70 + .../org.apache.tuscany.sca.databinding.DataBinding | 20 + ....apache.tuscany.sca.databinding.PullTransformer | 30 + .../sca/databinding/axiom/OMElementTestCase.java | 129 ++ .../databinding-axiom/src/test/resources/ipo.xml | 51 + .../databinding-axiom/src/test/resources/ipo.xsd | 137 ++ .../src/test/resources/order.wsdl | 76 + .../modules/databinding-jaxb-axiom/LICENSE | 205 +++ .../databinding-jaxb-axiom/META-INF/MANIFEST.MF | 40 + .../modules/databinding-jaxb-axiom/NOTICE | 6 + .../modules/databinding-jaxb-axiom/pom.xml | 175 ++ .../sca/databinding/jaxb/axiom/AxiomHelper.java | 140 ++ .../sca/databinding/jaxb/axiom/JAXB2OMElement.java | 81 + .../sca/databinding/jaxb/axiom/JAXBDataSource.java | 129 ++ .../sca/databinding/jaxb/axiom/OMElement2JAXB.java | 100 ++ .../jaxb/axiom/ext/JAXBCustomBuilder.java | 114 ++ .../databinding/jaxb/axiom/ext/JAXBDSContext.java | 189 +++ .../jaxb/axiom/ext/JAXBDataSourceExt.java | 144 ++ .../jaxb/axiom/ext/SourceDataSource.java | 123 ++ .../jaxb/axiom/ext/XMLStreamWriterWithOS.java | 246 +++ .../jaxb/axiom/ext/XMLStringDataSource.java | 84 + ....apache.tuscany.sca.databinding.PullTransformer | 26 + .../databinding/jaxb/axiom/JAXB2OMTestCase.java | 110 ++ .../jaxb/axiom/OMElement2JAXBTestCase.java | 71 + .../src/test/resources/ipo.xsd | 136 ++ .../modules/databinding-jaxb/LICENSE | 205 +++ .../modules/databinding-jaxb/META-INF/MANIFEST.MF | 55 + .../modules/databinding-jaxb/NOTICE | 6 + .../modules/databinding-jaxb/pom.xml | 175 ++ .../sca/databinding/jaxb/AnyTypeXmlAdapter.java | 39 + .../sca/databinding/jaxb/DOMElementXmlAdapter.java | 57 + .../sca/databinding/jaxb/DataConverter.java | 378 +++++ .../jaxb/DefaultXMLAdapterExtensionPoint.java | 60 + .../tuscany/sca/databinding/jaxb/JAXB2Node.java | 83 + .../tuscany/sca/databinding/jaxb/JAXB2SAX.java | 70 + .../tuscany/sca/databinding/jaxb/JAXB2String.java | 77 + .../sca/databinding/jaxb/JAXBContextCache.java | 555 +++++++ .../sca/databinding/jaxb/JAXBContextHelper.java | 478 ++++++ .../sca/databinding/jaxb/JAXBDataBinding.java | 134 ++ .../databinding/jaxb/JAXBPropertyDescriptor.java | 302 ++++ .../sca/databinding/jaxb/JAXBTypeHelper.java | 242 +++ .../sca/databinding/jaxb/JAXBWrapperException.java | 56 + .../sca/databinding/jaxb/JAXBWrapperHandler.java | 151 ++ .../sca/databinding/jaxb/JAXBWrapperHelper.java | 166 ++ .../tuscany/sca/databinding/jaxb/Node2JAXB.java | 73 + .../tuscany/sca/databinding/jaxb/Reader2JAXB.java | 74 + .../tuscany/sca/databinding/jaxb/String2JAXB.java | 80 + .../databinding/jaxb/XMLAdapterExtensionPoint.java | 52 + .../sca/databinding/jaxb/XMLRootElementUtil.java | 299 ++++ .../sca/databinding/jaxb/XMLStreamReader2JAXB.java | 77 + .../org.apache.tuscany.sca.databinding.DataBinding | 19 + ....apache.tuscany.sca.databinding.PullTransformer | 32 + ...y.sca.databinding.jaxb.XMLAdapterExtensionPoint | 17 + .../java/com/example/stock/StockQuoteOffer.java | 45 + .../databinding/jaxb/JAXBContextCacheTestCase.java | 121 ++ .../databinding/jaxb/JAXBDataBindingTestCase.java | 131 ++ .../databinding/jaxb/JAXBReflectionTestCase.java | 39 + .../tuscany/sca/databinding/jaxb/JAXBTestCase.java | 148 ++ .../jaxb/JAXBWrapperHandlerTestCase.java | 90 ++ .../tuscany/sca/databinding/jaxb/MyBean.java | 162 ++ .../tuscany/sca/databinding/jaxb/MyInterface.java | 29 + .../sca/databinding/jaxb/MyInterfaceImpl.java | 67 + .../tuscany/sca/databinding/jaxb/MyJaxbBean.java | 64 + .../tuscany/sca/databinding/jaxb/MySubBean.java | 35 + .../tuscany/sca/databinding/jaxb/POJOTestCase.java | 238 +++ .../databinding-jaxb/src/test/resources/ipo.xsd | 144 ++ .../modules/databinding-json/LICENSE | 202 +++ .../modules/databinding-json/META-INF/MANIFEST.MF | 33 + .../modules/databinding-json/NOTICE | 6 + .../modules/databinding-json/pom.xml | 124 ++ .../sca/databinding/json/JSON2JavaBean.java | 72 + .../tuscany/sca/databinding/json/JSON2String.java | 61 + .../sca/databinding/json/JSON2XMLStreamReader.java | 65 + .../sca/databinding/json/JSONDataBinding.java | 74 + .../tuscany/sca/databinding/json/JSONHelper.java | 89 ++ .../sca/databinding/json/JavaBean2JSON.java | 81 + .../sca/databinding/json/JavaBean2JSONObject.java | 142 ++ .../tuscany/sca/databinding/json/String2JSON.java | 64 + .../sca/databinding/json/XMLStreamReader2JSON.java | 83 + .../sca/databinding/json/axiom/JSON2OMElement.java | 94 ++ .../json/axiom/JSONBadgerfishDataSource.java | 57 + .../sca/databinding/json/axiom/JSONDataSource.java | 176 +++ .../org.apache.tuscany.sca.databinding.DataBinding | 19 + ....apache.tuscany.sca.databinding.PullTransformer | 31 + .../databinding/json/JSONTransformerTestCase.java | 137 ++ .../databinding/json/JavaBean2JSONTestCase.java | 170 ++ .../tuscany/sca/databinding/json/MyBean.java | 158 ++ .../tuscany/sca/databinding/json/MyInterface.java | 29 + .../sca/databinding/json/MyInterfaceImpl.java | 67 + .../tuscany/sca/databinding/json/POJOTestCase.java | 92 ++ .../databinding-json/src/test/resources/ipo.xsd | 136 ++ .../sca-java-2.0-M4/modules/databinding/LICENSE | 244 +++ .../modules/databinding/META-INF/MANIFEST.MF | 73 + .../sca-java-2.0-M4/modules/databinding/NOTICE | 6 + .../sca-java-2.0-M4/modules/databinding/pom.xml | 97 ++ .../tuscany/sca/databinding/DataBinding.java | 91 ++ .../sca/databinding/DataBindingExtensionPoint.java | 74 + .../apache/tuscany/sca/databinding/DataPipe.java | 46 + .../sca/databinding/DataPipeTransformer.java | 29 + .../DefaultDataBindingExtensionPoint.java | 261 +++ .../DefaultTransformerExtensionPoint.java | 321 ++++ .../apache/tuscany/sca/databinding/Mediator.java | 153 ++ .../tuscany/sca/databinding/PullTransformer.java | 38 + .../tuscany/sca/databinding/PushTransformer.java | 36 + .../tuscany/sca/databinding/SimpleTypeMapper.java | 69 + .../sca/databinding/TransformationContext.java | 95 ++ .../sca/databinding/TransformationException.java | 65 + .../tuscany/sca/databinding/Transformer.java | 51 + .../sca/databinding/TransformerExtensionPoint.java | 81 + .../tuscany/sca/databinding/WrapperHandler.java | 78 + .../tuscany/sca/databinding/XMLTypeHelper.java | 68 + .../sca/databinding/annotation/DataBinding.java | 56 + .../sca/databinding/annotation/DataType.java | 43 + .../externalizable/ExternalizableDataBinding.java | 39 + .../sca/databinding/impl/BaseDataBinding.java | 110 ++ .../sca/databinding/impl/BaseTransformer.java | 52 + .../sca/databinding/impl/DirectedGraph.java | 452 ++++++ .../databinding/impl/Group2GroupTransformer.java | 90 ++ .../sca/databinding/impl/GroupDataBinding.java | 103 ++ .../impl/Java2SimpleTypeTransformer.java | 70 + .../tuscany/sca/databinding/impl/MediatorImpl.java | 581 +++++++ .../sca/databinding/impl/PipedTransformer.java | 70 + .../impl/SimpleType2JavaTransformer.java | 89 ++ .../sca/databinding/impl/SimpleTypeMapperImpl.java | 401 +++++ .../impl/TransformationContextImpl.java | 129 ++ .../sca/databinding/impl/XSDDataTypeConverter.java | 945 +++++++++++ .../javabeans/DOMNode2JavaBeanTransformer.java | 98 ++ .../javabeans/Java2XMLMapperException.java | 69 + .../javabeans/JavaBean2DOMNodeTransformer.java | 76 + .../JavaBean2XMLStreamReaderTransformer.java | 68 + .../javabeans/JavaBean2XMLTransformer.java | 262 +++ .../javabeans/JavaBeansDataBinding.java | 162 ++ .../javabeans/JavaExceptionDataBinding.java | 35 + .../javabeans/SimpleJavaDataBinding.java | 84 + .../javabeans/XML2JavaBeanTransformer.java | 329 ++++ .../javabeans/XML2JavaMapperException.java | 76 + .../sca/databinding/util/DataTypeHelper.java | 165 ++ .../tuscany/sca/databinding/util/LRUCache.java | 88 ++ .../databinding/xml/BeanXMLStreamReaderImpl.java | 300 ++++ .../sca/databinding/xml/DOMDataBinding.java | 126 ++ .../sca/databinding/xml/DOMWrapperHandler.java | 138 ++ .../sca/databinding/xml/InputSource2Node.java | 67 + .../sca/databinding/xml/InputSource2SAX.java | 65 + .../sca/databinding/xml/InputStream2Node.java | 69 + .../sca/databinding/xml/InputStream2SAX.java | 64 + .../sca/databinding/xml/Node2OutputStream.java | 68 + .../sca/databinding/xml/Node2SimpleJavaType.java | 45 + .../databinding/xml/Node2SourceTransformer.java | 61 + .../tuscany/sca/databinding/xml/Node2String.java | 62 + .../tuscany/sca/databinding/xml/Node2Writer.java | 67 + .../sca/databinding/xml/Node2XMLStreamReader.java | 65 + .../tuscany/sca/databinding/xml/Reader2Node.java | 67 + .../tuscany/sca/databinding/xml/Reader2SAX.java | 60 + .../tuscany/sca/databinding/xml/SAX2DOMPipe.java | 78 + .../sca/databinding/xml/SimpleJavaType2Node.java | 66 + .../databinding/xml/Source2NodeTransformer.java | 70 + .../databinding/xml/Source2ResultTransformer.java | 63 + .../databinding/xml/Source2StringTransformer.java | 68 + .../sca/databinding/xml/StAXDataBinding.java | 53 + .../sca/databinding/xml/StreamDataPipe.java | 65 + .../tuscany/sca/databinding/xml/String2Node.java | 60 + .../tuscany/sca/databinding/xml/String2SAX.java | 61 + .../databinding/xml/String2SourceTransformer.java | 62 + .../databinding/xml/String2XMLStreamReader.java | 62 + .../sca/databinding/xml/Writer2ReaderDataPipe.java | 63 + .../sca/databinding/xml/XMLGroupDataBinding.java | 57 + .../sca/databinding/xml/XMLStreamReader2Node.java | 81 + .../sca/databinding/xml/XMLStreamReader2SAX.java | 77 + .../databinding/xml/XMLStreamReader2String.java | 64 + .../sca/databinding/xml/XMLStringDataBinding.java | 50 + .../org.apache.tuscany.sca.databinding.DataBinding | 25 + ...scany.sca.databinding.DataBindingExtensionPoint | 18 + .../org.apache.tuscany.sca.databinding.Mediator | 17 + ....apache.tuscany.sca.databinding.PullTransformer | 40 + ....apache.tuscany.sca.databinding.PushTransformer | 26 + ...apache.tuscany.sca.databinding.SimpleTypeMapper | 17 + ...scany.sca.databinding.TransformerExtensionPoint | 18 + .../extension/DataBindingExtensionTestCase.java | 82 + .../SimpleTypeMapperExtensionTestCase.java.fixme | 124 ++ .../TransformerExtensionTestCase.java.fixme | 77 + .../extension/XSDDataTypeConverterTestCase.java | 58 + .../sca/databinding/impl/DataBindingTestCase.java | 48 + .../databinding/impl/DirectedGraphTestCase.java | 123 ++ .../sca/databinding/impl/MediatorImplTestCase.java | 125 ++ .../impl/XMLDocumentStreamReaderTestCase.java | 60 + .../xml/BeanXMLStreamReaderTestCase.java | 188 +++ .../sca/databinding/xml/DOM2StAXTestCase.java | 116 ++ .../sca/databinding/xml/DataPipeTestCase.java | 96 ++ .../xml/JavaBean2XMLStreamReaderTestCase.java | 137 ++ .../sca/databinding/xml/Node2StringTestCase.java | 41 + .../xml/PushTransformationTestCase.java | 81 + .../databinding/xml/TraxTransformerTestCase.java | 99 ++ .../apache/tuscany/sca/databinding/impl/ipo.xsd | 136 ++ .../apache/tuscany/sca/databinding/impl/order.wsdl | 76 + .../org/apache/tuscany/sca/databinding/xml/foo.xml | 22 + .../sca-java-2.0-M4/modules/deployment/LICENSE | 205 +++ .../modules/deployment/META-INF/MANIFEST.MF | 49 + branches/sca-java-2.0-M4/modules/deployment/NOTICE | 6 + .../sca-java-2.0-M4/modules/deployment/pom.xml | 76 + .../tuscany/sca/deployment/DefaultDeployer.java | 42 + .../apache/tuscany/sca/deployment/Deployer.java | 191 +++ .../tuscany/sca/deployment/impl/Contributions.java | 160 ++ .../tuscany/sca/deployment/impl/DeployerImpl.java | 545 +++++++ .../org.apache.tuscany.sca.deployment.Deployer | 17 + .../deployer-impl-validation-messages.properties | 22 + .../src/test/java/hello/deployer/HelloWorld.java | 30 + .../test/java/hello/deployer/HelloWorldImpl.java | 30 + .../sca/deployment/impl/DeployerImplTestCase.java | 135 ++ .../test/resources/META-INF/sca-contribution.xml | 24 + .../sca/deployment/impl/HelloWorld.composite | 29 + .../sca-java-2.0-M4/modules/domain-node/LICENSE | 205 +++ .../modules/domain-node/META-INF/MANIFEST.MF | 18 + .../sca-java-2.0-M4/modules/domain-node/NOTICE | 6 + .../sca-java-2.0-M4/modules/domain-node/pom.xml | 63 + .../sca/domain/node/ConfigAttributesImpl.java | 35 + .../apache/tuscany/sca/domain/node/DomainNode.java | 157 ++ .../tuscany/sca/domain/node/DomainNodeMain.java | 63 + .../src/test/java/itest/nodes/Helloworld.java | 29 + .../tuscany/sca/domain/node/ConfigTestCase.java | 64 + .../domain/node/MultipleNodesPerJVMTestCase.java | 91 ++ .../tuscany/sca/domain/node/OneNodeTestCase.java | 102 ++ .../sca/domain/node/StopStartNodesTestCase.java | 78 + .../itest-nodes-helloworld-client-2.0-SNAPSHOT.jar | Bin 0 -> 4708 bytes ...itest-nodes-helloworld-service-2.0-SNAPSHOT.jar | Bin 0 -> 4515 bytes .../modules/endpoint-dht/META-INF/MANIFEST.MF | 19 + .../sca-java-2.0-M4/modules/endpoint-dht/README | 1 + branches/sca-java-2.0-M4/modules/endpoint-dht/TODO | 3 + .../sca-java-2.0-M4/modules/endpoint-dht/pom.xml | 47 + .../sca/endpoint/dht/OverlayEndpointRegistry.java | 327 ++++ ...org.apache.tuscany.sca.runtime.EndpointRegistry | 17 + .../modules/endpoint-tribes/META-INF/MANIFEST.MF | 28 + .../modules/endpoint-tribes/pom.xml | 47 + .../sca/endpoint/tribes/AbstractReplicatedMap.java | 1564 ++++++++++++++++++ .../tuscany/sca/endpoint/tribes/MapStore.java | 83 + .../tribes/ReplicatedEndpointRegistry.java | 451 ++++++ .../tuscany/sca/endpoint/tribes/ReplicatedMap.java | 125 ++ ...org.apache.tuscany.sca.runtime.EndpointRegistry | 17 + .../tribes/ReplicatedEndpointRegistryTestCase.java | 78 + .../modules/extensibility-equinox/LICENSE | 205 +++ .../extensibility-equinox/META-INF/MANIFEST.MF | 31 + .../modules/extensibility-equinox/NOTICE | 5 + .../modules/extensibility-equinox/pom.xml | 66 + .../equinox/EquinoxServiceDiscoverer.java | 319 ++++ .../equinox/EquinoxServiceDiscoveryActivator.java | 43 + .../equinox/OSGiExtensionPointRegistry.java | 125 ++ .../extensibility/equinox/EquinoxHostTestCase.java | 95 ++ .../equinox/EquinoxServiceDiscovererTestCase.java | 155 ++ .../sca/extensibility/equinox/TestEquinoxHost.java | 77 + .../src/test/resources/test-bundle.jar | Bin 0 -> 1797 bytes .../sca-java-2.0-M4/modules/extensibility/LICENSE | 205 +++ .../modules/extensibility/META-INF/MANIFEST.MF | 21 + .../sca-java-2.0-M4/modules/extensibility/NOTICE | 6 + .../sca-java-2.0-M4/modules/extensibility/pom.xml | 31 + .../sca/core/DefaultExtensionPointRegistry.java | 182 +++ .../sca/core/DefaultFactoryExtensionPoint.java | 162 ++ .../core/DefaultModuleActivatorExtensionPoint.java | 155 ++ .../sca/core/DefaultUtilityExtensionPoint.java | 220 +++ .../tuscany/sca/core/ExtensionPointRegistry.java | 56 + .../tuscany/sca/core/FactoryExtensionPoint.java | 54 + .../apache/tuscany/sca/core/LifeCycleListener.java | 36 + .../apache/tuscany/sca/core/ModuleActivator.java | 71 + .../sca/core/ModuleActivatorExtensionPoint.java | 53 + .../tuscany/sca/core/UtilityExtensionPoint.java | 73 + .../ContextClassLoaderServiceDiscoverer.java | 251 +++ .../sca/extensibility/ServiceDeclaration.java | 81 + .../extensibility/ServiceDeclarationParser.java | 292 ++++ .../sca/extensibility/ServiceDiscoverer.java | 54 + .../sca/extensibility/ServiceDiscovery.java | 356 +++++ .../tuscany/sca/extensibility/ServiceHelper.java | 225 +++ .../extensibility/impl/InvalidSyntaxException.java | 86 + .../tuscany/sca/extensibility/impl/LDAPFilter.java | 1357 ++++++++++++++++ ...g.apache.tuscany.sca.core.FactoryExtensionPoint | 18 + ....tuscany.sca.core.ModuleActivatorExtensionPoint | 18 + ...g.apache.tuscany.sca.core.UtilityExtensionPoint | 18 + ...ontextClassLoaderServiceDiscovererTestCase.java | 81 + .../DefaultExtensionPointRegistryTestCase.java | 58 + .../DefaultUtilityExtensionPointTestCase.java | 117 ++ .../extensibility/ServiceDiscoveryTestCase.java | 87 + .../sca/extensibility/ServiceHelperTestCase.java | 79 + .../tuscany/sca/extensibility/test/DummyImpl.java | 31 + .../tuscany/sca/extensibility/test/Test2Impl.java | 103 ++ .../tuscany/sca/extensibility/test/TestImpl.java | 42 + .../sca/extensibility/test/TestInterface.java | 30 + ...he.tuscany.sca.extensibility.test.TestInterface | 19 + .../sca-java-2.0-M4/modules/host-http-osgi/LICENSE | 205 +++ .../modules/host-http-osgi/META-INF/MANIFEST.MF | 25 + .../sca-java-2.0-M4/modules/host-http-osgi/NOTICE | 6 + .../sca-java-2.0-M4/modules/host-http-osgi/pom.xml | 74 + .../tuscany/sca/http/osgi/HttpServiceWrapper.java | 145 ++ .../tuscany/sca/http/osgi/OSGiServletHost.java | 275 ++++ .../sca/http/osgi/ServletRequestDispatcher.java | 114 ++ .../sca/http/osgi/OSGiServletHostTestCase.java | 97 ++ .../src/test/resources/content/test.html | 23 + .../src/test/resources/tuscany.keyStore | Bin 0 -> 1265 bytes branches/sca-java-2.0-M4/modules/host-http/LICENSE | 205 +++ .../modules/host-http/META-INF/MANIFEST.MF | 21 + branches/sca-java-2.0-M4/modules/host-http/NOTICE | 6 + branches/sca-java-2.0-M4/modules/host-http/pom.xml | 46 + .../sca/host/http/DefaultResourceServlet.java | 86 + .../http/DefaultServletHostExtensionPoint.java | 198 +++ .../sca/host/http/ExtensibleServletHost.java | 131 ++ .../apache/tuscany/sca/host/http/ServletHost.java | 120 ++ .../sca/host/http/ServletHostExtensionPoint.java | 51 + .../sca/host/http/ServletMappingException.java | 44 + ...tuscany.sca.host.http.ServletHostExtensionPoint | 18 + .../sca-java-2.0-M4/modules/host-jetty/LICENSE | 205 +++ .../modules/host-jetty/META-INF/MANIFEST.MF | 29 + branches/sca-java-2.0-M4/modules/host-jetty/NOTICE | 6 + .../sca-java-2.0-M4/modules/host-jetty/pom.xml | 69 + .../sca/http/jetty/JettyDefaultServlet.java | 90 ++ .../apache/tuscany/sca/http/jetty/JettyLogger.java | 107 ++ .../apache/tuscany/sca/http/jetty/JettyServer.java | 519 ++++++ .../org.apache.tuscany.sca.host.http.ServletHost | 18 + .../sca/http/jetty/JettyServerTestCase.java | 332 ++++ .../src/test/resources/content/test.html | 21 + .../host-jetty/src/test/resources/tuscany.keyStore | Bin 0 -> 1265 bytes .../sca-java-2.0-M4/modules/host-jetty7/LICENSE | 205 +++ .../modules/host-jetty7/META-INF/MANIFEST.MF | 29 + .../sca-java-2.0-M4/modules/host-jetty7/NOTICE | 6 + .../sca-java-2.0-M4/modules/host-jetty7/pom.xml | 57 + .../sca/http/jetty7/JettyDefaultServlet.java | 90 ++ .../tuscany/sca/http/jetty7/JettyServer.java | 520 ++++++ .../org.apache.tuscany.sca.host.http.ServletHost | 18 + .../sca/http/jetty7/JettyServerTestCase.java | 335 ++++ .../src/test/resources/content/test.html | 21 + .../src/test/resources/tuscany.keyStore | Bin 0 -> 1265 bytes branches/sca-java-2.0-M4/modules/host-rmi/LICENSE | 205 +++ .../modules/host-rmi/META-INF/MANIFEST.MF | 17 + branches/sca-java-2.0-M4/modules/host-rmi/NOTICE | 6 + branches/sca-java-2.0-M4/modules/host-rmi/pom.xml | 39 + .../tuscany/sca/host/rmi/DefaultRMIHost.java | 170 ++ .../sca/host/rmi/DefaultRMIHostExtensionPoint.java | 67 + .../tuscany/sca/host/rmi/ExtensibleRMIHost.java | 62 + .../org/apache/tuscany/sca/host/rmi/RMIHost.java | 60 + .../tuscany/sca/host/rmi/RMIHostException.java | 45 + .../sca/host/rmi/RMIHostExtensionPoint.java | 51 + .../sca/host/rmi/RMIHostRuntimeException.java | 46 + .../tuscany/sca/host/rmi/RMISocketFactoryImpl.java | 57 + ...ache.tuscany.sca.host.rmi.RMIHostExtensionPoint | 18 + .../tuscany/sca/host/rmi/RMIHostImplTestCase.java | 90 ++ .../sca-java-2.0-M4/modules/host-webapp/LICENSE | 205 +++ .../modules/host-webapp/META-INF/MANIFEST.MF | 25 + .../sca-java-2.0-M4/modules/host-webapp/NOTICE | 7 + .../sca-java-2.0-M4/modules/host-webapp/pom.xml | 73 + .../tuscany/sca/host/webapp/ServletHostHelper.java | 188 +++ .../sca/host/webapp/TuscanyContextListener.java | 59 + .../sca/host/webapp/TuscanyServletFilter.java | 109 ++ .../sca/host/webapp/WebAppRequestDispatcher.java | 117 ++ .../tuscany/sca/host/webapp/WebAppServletHost.java | 310 ++++ .../org.apache.tuscany.sca.host.http.ServletHost | 18 + .../modules/implementation-bpel-runtime/LICENSE | 251 +++ .../META-INF/MANIFEST.MF | 61 + .../modules/implementation-bpel-runtime/NOTICE | 17 + .../modules/implementation-bpel-runtime/pom.xml | 467 ++++++ .../implementation/bpel/ode/BPELODEDeployFile.java | 233 +++ .../bpel/ode/DeploymentWorkspace.java | 233 +++ .../implementation/bpel/ode/EmbeddedODEServer.java | 563 +++++++ .../implementation/bpel/ode/GeronimoTxFactory.java | 48 + .../implementation/bpel/ode/ODEBindingContext.java | 91 ++ .../sca/implementation/bpel/ode/ODEDeployment.java | 55 + .../bpel/ode/ODEDeploymentException.java | 41 + .../bpel/ode/ODEEndpointReference.java | 96 ++ .../sca/implementation/bpel/ode/ODEEprContext.java | 75 + .../bpel/ode/ODEExternalService.java | 373 +++++ .../bpel/ode/ODEInitializationException.java | 41 + .../bpel/ode/ODEMessageExchangeContext.java | 57 + .../bpel/ode/ODEShutdownException.java | 41 + .../sca/implementation/bpel/ode/TuscanyEPR.java | 49 + .../sca/implementation/bpel/ode/TuscanyPRC.java | 62 + .../bpel/ode/TuscanyProcessConfImpl.java | 756 +++++++++ .../ode/provider/BPELImplementationProvider.java | 177 +++ .../BPELImplementationProviderFactory.java | 69 + .../bpel/ode/provider/BPELInvoker.java | 286 ++++ .../bpel/ode/provider/ODEInvocationException.java | 33 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../bpel/ode/EmbeddedODEServerTestCase.java | 124 ++ .../src/test/resources/helloworld/deploy.xml | 30 + .../src/test/resources/helloworld/greetings.wsdl | 87 + .../src/test/resources/helloworld/helloworld.bpel | 81 + .../src/test/resources/helloworld/helloworld.wsdl | 82 + .../src/test/resources/log4j.properties | 36 + .../modules/implementation-bpel/LICENSE | 251 +++ .../implementation-bpel/META-INF/MANIFEST.MF | 34 + .../modules/implementation-bpel/NOTICE | 17 + .../modules/implementation-bpel/pom.xml | 64 + .../sca/implementation/bpel/BPELFactory.java | 42 + .../implementation/bpel/BPELImplementation.java | 91 ++ .../implementation/bpel/BPELProcessDefinition.java | 114 ++ .../implementation/bpel/impl/BPELFactoryImpl.java | 44 + .../bpel/impl/BPELImplementationImpl.java | 127 ++ .../bpel/impl/BPELProcessDefinitionImpl.java | 128 ++ .../bpel/xml/BPELDocumentModelResolver.java | 401 +++++ .../bpel/xml/BPELDocumentProcessor.java | 354 +++++ .../bpel/xml/BPELImplementationProcessor.java | 452 ++++++ .../implementation/bpel/xml/BPELImportElement.java | 65 + .../bpel/xml/BPELPartnerLinkElement.java | 132 ++ .../bpel/xml/BPELPartnerLinkTypeElement.java | 118 ++ .../bpel/xml/BPELProcessorConstants.java | 61 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...sca.contribution.processor.URLArtifactProcessor | 19 + ...tuscany.sca.contribution.resolver.ModelResolver | 18 + ...che.tuscany.sca.implementation.bpel.BPELFactory | 18 + .../impl-bpel-validation-messages.properties | 34 + .../bpel/BPELDocumentProcessorTestCase.java | 62 + .../bpel/BPELImplementationProcessorTestCase.java | 102 ++ .../src/test/resources/helloworld/helloworld.bpel | 66 + .../src/test/resources/helloworld/helloworld.wsdl | 82 + .../modules/implementation-java-runtime/LICENSE | 205 +++ .../META-INF/MANIFEST.MF | 62 + .../modules/implementation-java-runtime/NOTICE | 6 + .../modules/implementation-java-runtime/pom.xml | 57 + .../java/context/InstanceFactory.java | 43 + .../java/context/InstanceFactoryProvider.java | 49 + .../java/context/ReflectiveInstanceFactory.java | 91 ++ .../java/context/ReflectiveInstanceWrapper.java | 64 + .../injection/ArrayMultiplicityObjectFactory.java | 54 + .../java/injection/ContextInjector.java | 32 + .../java/injection/FieldInjector.java | 67 + .../java/injection/InjectionRuntimeException.java | 46 + .../implementation/java/injection/Injector.java | 35 + .../java/injection/InvalidAccessorException.java | 43 + .../injection/JavaPropertyValueObjectFactory.java | 327 ++++ .../injection/ListMultiplicityObjectFactory.java | 50 + .../java/injection/MethodInjector.java | 64 + .../injection/RequestContextObjectFactory.java | 44 + .../java/injection/ResourceHost.java | 46 + .../java/injection/ResourceNotFoundException.java | 47 + .../java/injection/ResourceObjectFactory.java | 86 + .../injection/ResourceResolutionException.java | 43 + .../java/invocation/EventInvocationException.java | 47 + .../java/invocation/EventInvoker.java | 34 + .../InvalidConversationSequenceException.java | 45 + .../JavaCallbackRuntimeWireProcessor.java | 120 ++ .../invocation/JavaComponentContextFactory.java | 40 + .../invocation/JavaComponentContextProvider.java | 374 +++++ .../java/invocation/JavaComponentNameFactory.java | 40 + .../java/invocation/JavaImplementationInvoker.java | 207 +++ .../invocation/JavaImplementationProvider.java | 176 +++ .../JavaImplementationProviderFactory.java | 108 ++ .../invocation/JavaInstanceFactoryProvider.java | 182 +++ .../java/invocation/MethodEventInvoker.java | 56 + .../NoConversationalContractException.java | 33 + ...apache.tuscany.sca.context.PropertyValueFactory | 17 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...cany.sca.provider.ImplementationProviderFactory | 19 + ...apache.tuscany.sca.runtime.RuntimeWireProcessor | 17 + .../java/definitions/definitions.xml | 30 + .../java/context/MultiplicityTestCase.java | 36 + .../ReflectiveInstanceWrapperTestCase.java.fixme | 84 + .../CallbackWireObjectFactoryTestCase.java.fixme | 54 + .../java/injection/FieldInjectorTestCase.java | 52 + ...vaPropertyValueObjectFactoryTestCase.java.fixme | 449 ++++++ .../java/injection/MethodEventInvokerTestCase.java | 79 + .../java/injection/MethodInjectorTestCase.java | 83 + .../ResourceObjectFactoryTestCase.java.fixme | 89 ++ .../java/injection/SingletonObjectFactory.java | 39 + .../injection/SingletonObjectFactoryTestCase.java | 36 + .../java/injection/TestObjectFactory.java | 120 ++ .../java/injection/TestObjectFactoryTestCase.java | 82 + .../sca/implementation/java/util/Bean1.java | 50 + .../sca/implementation/java/util/Bean2.java | 49 + .../sca/implementation/java/util/Entry.java | 32 + .../java/util/JavaIntrospectionHelperTestCase.java | 189 +++ .../sca/implementation/java/util/SuperBean.java | 48 + .../modules/implementation-java/LICENSE | 205 +++ .../implementation-java/META-INF/MANIFEST.MF | 47 + .../modules/implementation-java/NOTICE | 6 + .../modules/implementation-java/pom.xml | 99 ++ .../java/BaseJavaImplementation.java | 59 + .../java/DefaultJavaImplementationFactory.java | 40 + .../java/IntrospectionException.java | 60 + .../implementation/java/JavaConstructorImpl.java | 56 + .../sca/implementation/java/JavaElementImpl.java | 222 +++ .../implementation/java/JavaImplementation.java | 184 +++ .../java/JavaImplementationFactory.java | 75 + .../sca/implementation/java/JavaParameterImpl.java | 36 + .../sca/implementation/java/JavaResourceImpl.java | 86 + .../sca/implementation/java/JavaScopeImpl.java | 62 + .../java/impl/BaseJavaImplementationImpl.java | 92 ++ .../java/impl/JavaClassIntrospectorImpl.java | 143 ++ .../java/impl/JavaImplementationFactoryImpl.java | 136 ++ .../java/impl/JavaImplementationImpl.java | 162 ++ .../java/introspect/BaseJavaClassVisitor.java | 74 + .../java/introspect/JavaClassVisitor.java | 126 ++ .../java/introspect/JavaIntrospectionHelper.java | 577 +++++++ .../introspect/impl/AbstractPropertyProcessor.java | 222 +++ .../impl/AllowsPassByReferenceProcessor.java | 57 + .../impl/AmbiguousConstructorException.java | 40 + .../introspect/impl/ComponentNameProcessor.java | 87 + .../java/introspect/impl/ConstructorProcessor.java | 110 ++ .../java/introspect/impl/ContextProcessor.java | 89 ++ .../java/introspect/impl/DestroyProcessor.java | 67 + .../impl/DuplicateConstructorException.java | 41 + .../impl/DuplicateDestructorException.java | 35 + .../introspect/impl/DuplicateInitException.java | 35 + .../impl/DuplicatePropertyException.java | 34 + .../impl/DuplicateReferenceException.java | 35 + .../impl/DuplicateResourceException.java | 36 + .../java/introspect/impl/EagerInitProcessor.java | 63 + .../introspect/impl/HeuristicPojoProcessor.java | 662 ++++++++ .../impl/IllegalCallbackReferenceException.java | 40 + .../introspect/impl/IllegalContextException.java | 40 + .../impl/IllegalDestructorException.java | 40 + .../java/introspect/impl/IllegalInitException.java | 40 + .../introspect/impl/IllegalPropertyException.java | 40 + .../introspect/impl/IllegalReferenceException.java | 40 + .../introspect/impl/IllegalResourceException.java | 40 + .../impl/IllegalServiceDefinitionException.java | 35 + .../java/introspect/impl/InitProcessor.java | 67 + .../impl/InvalidConstructorException.java | 36 + ...validConversationalImplementationException.java | 39 + .../introspect/impl/InvalidPropertyException.java | 35 + .../introspect/impl/InvalidReferenceException.java | 42 + .../introspect/impl/InvalidResourceException.java | 40 + .../impl/InvalidServiceTypeException.java | 48 + .../introspect/impl/NoConstructorException.java | 37 + .../java/introspect/impl/PolicyProcessor.java | 303 ++++ .../java/introspect/impl/PropertyProcessor.java | 50 + .../java/introspect/impl/ReferenceProcessor.java | 274 ++++ .../java/introspect/impl/Resource.java | 49 + .../java/introspect/impl/ResourceProcessor.java | 153 ++ .../java/introspect/impl/ScopeProcessor.java | 68 + .../java/introspect/impl/ServiceProcessor.java | 238 +++ .../impl/ServiceTypeNotFoundException.java | 35 + .../impl/UnknownContextTypeException.java | 33 + .../java/xml/JavaImplementationConstants.java | 35 + .../java/xml/JavaImplementationProcessor.java | 334 ++++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...a.implementation.java.JavaImplementationFactory | 18 + ...implementation.java.introspect.JavaClassVisitor | 33 + .../impl-javaxml-validation-messages.properties | 23 + .../src/test/java/calculator/AddService.java | 30 + .../src/test/java/calculator/AddServiceImpl.java | 37 + .../test/java/calculator/CalculatorService.java | 36 + .../java/calculator/CalculatorServiceImpl.java | 73 + .../src/test/java/calculator/DivideService.java | 30 + .../test/java/calculator/DivideServiceImpl.java | 35 + .../src/test/java/calculator/MultiplyService.java | 30 + .../test/java/calculator/MultiplyServiceImpl.java | 35 + .../src/test/java/calculator/SubtractService.java | 30 + .../test/java/calculator/SubtractServiceImpl.java | 35 + .../introspect/impl/AbstractProcessorTest.java | 80 + .../AllowsPassByReferenceProcessorTestCase.java | 74 + .../impl/ConstructorProcessorTestCase.java | 206 +++ .../impl/ConstructorPropertyTestCase.java | 174 ++ .../impl/ConstructorReferenceTestCase.java | 188 +++ .../impl/ConstructorResourceTestCase.java | 164 ++ .../introspect/impl/ContextProcessorTestCase.java | 216 +++ .../introspect/impl/DestroyProcessorTestCase.java | 136 ++ .../impl/EagerInitProcessorTestCase.java | 60 + .../impl/HeuristicAndPropertyTestCase.java | 72 + .../impl/HeuristicConstructorTestCase.java | 330 ++++ .../impl/HeuristicPojoProcessorTestCase.java | 583 +++++++ .../HeutisticExtensibleConstructorTestCase.java | 157 ++ .../introspect/impl/InitProcessorTestCase.java | 153 ++ .../java/introspect/impl/ModelHelper.java | 99 ++ .../introspect/impl/PolicyProcessorTestCase.java | 428 +++++ .../introspect/impl/PropertyProcessorTestCase.java | 304 ++++ .../impl/ReferenceProcessorTestCase.java | 310 ++++ .../introspect/impl/ResourceProcessorTestCase.java | 128 ++ .../introspect/impl/ScopeProcessorTestCase.java | 80 + .../introspect/impl/ServiceCallbackTestCase.java | 197 +++ .../introspect/impl/ServiceProcessorTestCase.java | 219 +++ .../TestAbstractPropertyProcessorTestCase.java | 180 +++ .../sca/implementation/java/xml/ReadTestCase.java | 241 +++ .../implementation/java/xml/TestModelResolver.java | 89 ++ .../sca/implementation/java/xml/WriteTestCase.java | 71 + .../implementation/java/xml/Calculator.composite | 66 + .../sca/implementation/java/xml/definitions.xml | 100 ++ .../java/xml/definitions_with_policysets.xml | 113 ++ .../modules/implementation-osgi-runtime/LICENSE | 203 +++ .../META-INF/MANIFEST.MF | 30 + .../modules/implementation-osgi-runtime/NOTICE | 6 + .../modules/implementation-osgi-runtime/pom.xml | 78 + .../osgi/runtime/OSGiDistributionProvider.java | 86 + .../osgi/runtime/OSGiImplementationProvider.java | 227 +++ .../runtime/OSGiImplementationProviderFactory.java | 59 + .../OSGiImplementationRuntimeActivator.java | 51 + .../osgi/runtime/OSGiTargetInvoker.java | 210 +++ .../src/main/resources/META-INF/definitions.xml | 37 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../impl-osgi-validation-messages.properties | 25 + .../modules/implementation-osgi/LICENSE | 203 +++ .../implementation-osgi/META-INF/MANIFEST.MF | 36 + .../modules/implementation-osgi/NOTICE | 6 + .../modules/implementation-osgi/pom.xml | 73 + .../osgi/DefaultOSGiImplementationFactory.java | 34 + .../osgi/DefaultServiceDescriptionsFactory.java | 33 + .../implementation/osgi/OSGiImplementation.java | 51 + .../osgi/OSGiImplementationFactory.java | 37 + .../sca/implementation/osgi/OSGiProperty.java | 179 +++ .../tuscany/sca/implementation/osgi/SCAConfig.java | 65 + .../implementation/osgi/ServiceDescription.java | 40 + .../implementation/osgi/ServiceDescriptions.java | 36 + .../osgi/ServiceDescriptionsFactory.java | 31 + .../osgi/impl/OSGiImplementationFactoryImpl.java | 43 + .../osgi/impl/OSGiImplementationImpl.java | 107 ++ .../implementation/osgi/impl/OSGiPropertyImpl.java | 51 + .../implementation/osgi/impl/SCAConfigImpl.java | 58 + .../osgi/impl/ServiceDescriptionImpl.java | 51 + .../osgi/impl/ServiceDescriptionsFactoryImpl.java | 48 + .../osgi/impl/ServiceDescriptionsImpl.java | 36 + .../osgi/xml/BluePrintComponentsProcessor.java | 144 ++ .../osgi/xml/OSGiComponentProcessor.java | 174 ++ .../osgi/xml/OSGiImplementationActivator.java | 47 + .../osgi/xml/OSGiImplementationProcessor.java | 342 ++++ .../osgi/xml/OSGiPropertyProcessor.java | 104 ++ .../osgi/xml/SCAConfigProcessor.java | 190 +++ .../xml/ServiceDescriptionsDocumentProcessor.java | 99 ++ .../osgi/xml/ServiceDescriptionsModelResolver.java | 59 + .../osgi/xml/ServiceDescriptionsProcessor.java | 191 +++ .../src/main/resources/META-INF/definitions.xml | 37 + ...ca.contribution.processor.StAXArtifactProcessor | 22 + ...sca.contribution.processor.URLArtifactProcessor | 19 + ...tuscany.sca.contribution.resolver.ModelResolver | 17 + ...a.implementation.osgi.OSGiImplementationFactory | 18 + ....implementation.osgi.ServiceDescriptionsFactory | 17 + .../impl-osgi-validation-messages.properties | 26 + .../java/calculator/dosgi/CalculatorService.java | 39 + .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../xml/BluePrintComponentsProcessorTestCase.java | 89 ++ .../osgi/xml/OSGiComponentProcessorTestCase.java | 89 ++ .../osgi/xml/OSGiReadImplTestCase.java | 139 ++ .../osgi/xml/ServiceDescriptionsTestCase.java | 108 ++ .../implementation/osgi/xml/TestModelResolver.java | 105 ++ .../resources/OSGI-INF/calculator-component.xml | 36 + .../resources/OSGI-INF/sca/bundle.componentType | 54 + .../src/test/resources/osgitest.composite | 35 + .../modules/implementation-spring-sca/LICENSE | 205 +++ .../implementation-spring-sca/META-INF/MANIFEST.MF | 26 + .../modules/implementation-spring-sca/NOTICE | 6 + .../modules/implementation-spring-sca/README | 9 + .../modules/implementation-spring-sca/pom.xml | 70 + .../namespace/SCANamespaceHandlerResolver.java | 53 + .../spring/namespace/ScaNamespaceHandler.java | 38 + .../namespace/ScaPropertyBeanDefinitionParser.java | 35 + .../ScaReferenceBeanDefinitionParser.java | 36 + .../namespace/ScaServiceBeanDefinitionParser.java | 36 + .../ComponentNameAnnotationProcessor.java | 150 ++ .../spring/processor/ComponentStub.java | 54 + .../processor/ConstructorAnnotationProcessor.java | 115 ++ .../processor/InitDestroyAnnotationProcessor.java | 75 + .../processor/PropertyAnnotationProcessor.java | 161 ++ .../spring/processor/PropertyValueStub.java | 55 + .../processor/ReferenceAnnotationProcessor.java | 164 ++ .../context/SCAGenericApplicationContext.java | 29 + .../context/SCAParentApplicationContext.java | 189 +++ .../spring/runtime/context/SpringContextTie.java | 133 ++ .../runtime/context/SpringImplementationStub.java | 129 ++ .../src/main/resources/META-INF/spring.handlers | 1 + .../src/main/resources/META-INF/spring.schemas | 1 + .../org/springframework/sca/xml/spring-sca.xsd | 84 + .../modules/implementation-spring/LICENSE | 205 +++ .../implementation-spring/META-INF/MANIFEST.MF | 55 + .../modules/implementation-spring/NOTICE | 6 + .../modules/implementation-spring/README | 9 + .../modules/implementation-spring/pom.xml | 69 + .../implementation/spring/SpringBeanElement.java | 117 ++ .../spring/SpringConstructorArgElement.java | 77 + .../spring/SpringImplementation.java | 228 +++ .../spring/SpringImplementationBuilder.java | 41 + .../spring/SpringImplementationConstants.java | 73 + .../spring/SpringPropertyElement.java | 60 + .../spring/SpringSCAPropertyElement.java | 52 + .../spring/SpringSCAReferenceElement.java | 78 + .../spring/SpringSCAServiceElement.java | 78 + .../spring/introspect/SpringBeanIntrospector.java | 99 ++ .../spring/introspect/SpringBeanPojoProcessor.java | 660 ++++++++ .../introspect/SpringXMLComponentTypeLoader.java | 1153 ++++++++++++++ .../spring/invocation/ComponentTie.java | 41 + .../spring/invocation/PropertyValueTie.java | 53 + .../spring/invocation/SpringContextStub.java | 134 ++ .../invocation/SpringImplementationProvider.java | 85 + .../SpringImplementationProviderFactory.java | 77 + .../spring/invocation/SpringImplementationTie.java | 147 ++ .../invocation/SpringInvocationException.java | 40 + .../spring/invocation/SpringInvoker.java | 124 ++ .../spring/xml/SpringImplementationProcessor.java | 230 +++ ...cany.sca.assembly.builder.ImplementationBuilder | 17 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../impl-spring-validation-messages.properties | 28 + .../sca/implementation/spring/definitions.xml | 30 + .../modules/implementation-web-client/LICENSE | 241 +++ .../implementation-web-client/META-INF/MANIFEST.MF | 32 + .../modules/implementation-web-client/NOTICE | 12 + .../modules/implementation-web-client/pom.xml | 68 + .../web/client/ClientImplementationProvider.java | 43 + .../web/client/ClientProviderFactory.java | 62 + .../implementation/web/client/ClientServlet.java | 273 ++++ ...cany.sca.provider.ImplementationProviderFactory | 21 + .../modules/implementation-web-runtime/LICENSE | 241 +++ .../META-INF/MANIFEST.MF | 29 + .../modules/implementation-web-runtime/NOTICE | 12 + .../modules/implementation-web-runtime/pom.xml | 96 ++ .../web/runtime/ComponentContextProxy.java | 85 + .../runtime/WebImplementationProviderFactory.java | 69 + .../web/runtime/jsp/ReferenceTEI.java | 45 + .../web/runtime/jsp/ReferenceTag.java | 97 ++ .../web/runtime/utils/ContextHelper.java | 133 ++ .../src/main/resources/META-INF/sca.tld | 49 + ...cany.sca.provider.ImplementationProviderFactory | 20 + .../modules/implementation-web/LICENSE | 205 +++ .../implementation-web/META-INF/MANIFEST.MF | 30 + .../modules/implementation-web/NOTICE | 6 + .../modules/implementation-web/pom.xml | 73 + .../sca/implementation/web/WebImplementation.java | 45 + .../web/WebImplementationFactory.java | 34 + .../web/impl/WebImplementationBuilder.java | 43 + .../web/impl/WebImplementationFactoryImpl.java | 37 + .../web/impl/WebImplementationImpl.java | 135 ++ .../web/xml/WebImplementationProcessor.java | 121 ++ ...cany.sca.assembly.builder.ImplementationBuilder | 17 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...sca.implementation.web.WebImplementationFactory | 19 + .../sca/implementation/web/xml/ReadTestCase.java | 64 + .../sca/implementation/web/xml/WriteTestCase.java | 69 + .../sca/implementation/web/xml/TestWeb.composite | 29 + .../modules/interface-java-jaxws/LICENSE | 205 +++ .../interface-java-jaxws/META-INF/MANIFEST.MF | 50 + .../modules/interface-java-jaxws/NOTICE | 6 + .../modules/interface-java-jaxws/pom.xml | 281 ++++ .../interfacedef/java/jaxws/BaseBeanGenerator.java | 542 +++++++ .../java/jaxws/CodeGenerationHelper.java | 280 ++++ .../java/jaxws/FaultBeanGenerator.java | 147 ++ .../java/jaxws/GeneratedClassLoader.java | 70 + .../java/jaxws/GeneratedDataTypeImpl.java | 143 ++ .../java/jaxws/JAXWSAsyncInterfaceProcessor.java | 276 ++++ .../java/jaxws/JAXWSFaultExceptionMapper.java | 403 +++++ .../java/jaxws/JAXWSJavaInterfaceProcessor.java | 393 +++++ .../java/jaxws/WebServiceInterfaceProcessor.java | 49 + .../java/jaxws/WrapperBeanGenerator.java | 238 +++ ...e.tuscany.sca.interfacedef.FaultExceptionMapper | 17 + ...terfacedef.java.introspect.JavaInterfaceVisitor | 19 + .../tuscany/sca/interfacedef/java/jaxws/Bean.java | 27 + .../tuscany/sca/interfacedef/java/jaxws/Bean1.java | 40 + .../tuscany/sca/interfacedef/java/jaxws/Bean2.java | 40 + .../sca/interfacedef/java/jaxws/BeanInterface.java | 28 + .../interfacedef/java/jaxws/BeanInterfaceImpl.java | 35 + .../java/jaxws/FaultBeanGeneratorTestCase.java | 64 + .../JAXWSAsyncInterfaceProcessorTestCase.java | 67 + .../jaxws/JAXWSJavaInterfaceProcessorTestCase.java | 121 ++ .../java/jaxws/JavaReflectionHelperTestCase.java | 47 + .../sca/interfacedef/java/jaxws/MyException.java | 62 + .../sca/interfacedef/java/jaxws/MyServiceImpl.java | 52 + .../sca/interfacedef/java/jaxws/StockQuote.java | 44 + .../sca/interfacedef/java/jaxws/TestAdapter.java | 39 + .../interfacedef/java/jaxws/TestGenericClass.java | 40 + .../sca/interfacedef/java/jaxws/TestInterface.java | 70 + .../java/jaxws/WrapperBeanGeneratorTestCase.java | 79 + .../src/test/resources/wsdl/Stock.wsdl | 142 ++ .../test/resources/wsdl/StockExceptionTest.wsdl | 171 ++ .../sca-java-2.0-M4/modules/interface-java/LICENSE | 205 +++ .../modules/interface-java/META-INF/MANIFEST.MF | 43 + .../sca-java-2.0-M4/modules/interface-java/NOTICE | 6 + .../sca-java-2.0-M4/modules/interface-java/pom.xml | 59 + .../java/DefaultJavaInterfaceFactory.java | 100 ++ .../sca/interfacedef/java/JavaInterface.java | 88 ++ .../interfacedef/java/JavaInterfaceContract.java | 32 + .../interfacedef/java/JavaInterfaceFactory.java | 90 ++ .../sca/interfacedef/java/JavaOperation.java | 57 + .../java/impl/JavaInterfaceContractImpl.java | 39 + .../java/impl/JavaInterfaceFactoryImpl.java | 93 ++ .../interfacedef/java/impl/JavaInterfaceImpl.java | 139 ++ .../java/impl/JavaInterfaceIntrospectorImpl.java | 278 ++++ .../interfacedef/java/impl/JavaInterfaceUtil.java | 173 ++ .../interfacedef/java/impl/JavaOperationImpl.java | 83 + .../java/impl/PolicyJavaInterfaceVisitor.java | 210 +++ .../java/introspect/JavaInterfaceVisitor.java | 39 + .../sca/interfacedef/java/xml/JavaConstants.java | 36 + .../java/xml/JavaInterfaceProcessor.java | 346 ++++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...cany.sca.interfacedef.java.JavaInterfaceFactory | 18 + ...terfacedef.java.introspect.JavaInterfaceVisitor | 17 + ...nterface-javaxml-validation-messages.properties | 27 + ...avaInterfaceUtilDuplicateRemotableTestCase.java | 317 ++++ .../java/impl/JavaInterfaceUtilTestCase.java | 123 ++ ...terfaceProcessorRegistryImplTestCase.java.fixme | 107 ++ .../impl/PolicyProcessorTestCase.java | 119 ++ .../sca/interfacedef/java/xml/ReadTestCase.java | 81 + .../sca/interfacedef/java/xml/WriteTestCase.java | 80 + .../sca/interfacedef/java/xml/Calculator.composite | 53 + .../java/xml/CalculatorImpl.componentType | 31 + .../sca-java-2.0-M4/modules/interface-wsdl/LICENSE | 205 +++ .../modules/interface-wsdl/META-INF/MANIFEST.MF | 48 + .../sca-java-2.0-M4/modules/interface-wsdl/NOTICE | 6 + .../sca-java-2.0-M4/modules/interface-wsdl/pom.xml | 87 + .../interfacedef/wsdl/BPELPartnerLinkTypeExt.java | 79 + .../sca/interfacedef/wsdl/DefaultWSDLFactory.java | 35 + .../sca/interfacedef/wsdl/WSDLDefinition.java | 140 ++ .../tuscany/sca/interfacedef/wsdl/WSDLFactory.java | 71 + .../sca/interfacedef/wsdl/WSDLInterface.java | 79 + .../interfacedef/wsdl/WSDLInterfaceContract.java | 43 + .../tuscany/sca/interfacedef/wsdl/WSDLObject.java | 54 + .../sca/interfacedef/wsdl/WSDLOperation.java | 40 + .../wsdl/impl/InvalidWSDLException.java | 35 + .../interfacedef/wsdl/impl/WSDLDefinitionImpl.java | 284 ++++ .../interfacedef/wsdl/impl/WSDLFactoryImpl.java | 80 + .../wsdl/impl/WSDLInterfaceContractImpl.java | 47 + .../interfacedef/wsdl/impl/WSDLInterfaceImpl.java | 124 ++ .../wsdl/impl/WSDLInterfaceIntrospectorImpl.java | 187 +++ .../sca/interfacedef/wsdl/impl/WSDLObjectImpl.java | 61 + .../interfacedef/wsdl/impl/WSDLOperationImpl.java | 81 + .../wsdl/impl/WSDLOperationIntrospectorImpl.java | 607 +++++++ .../wsdl/xml/BPELExtensionHandler.java | 142 ++ .../sca/interfacedef/wsdl/xml/WSDLConstants.java | 39 + .../wsdl/xml/WSDLDocumentProcessor.java | 221 +++ .../wsdl/xml/WSDLInterfaceProcessor.java | 382 +++++ .../interfacedef/wsdl/xml/WSDLModelResolver.java | 535 +++++++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...sca.contribution.processor.URLArtifactProcessor | 19 + ...tuscany.sca.contribution.resolver.ModelResolver | 18 + ...pache.tuscany.sca.interfacedef.wsdl.WSDLFactory | 18 + ...nterface-wsdlxml-validation-messages.properties | 26 + .../WSDLInterfaceIntrospectorTestCase.java | 85 + .../WSDLOperationIntrospectorTestCase.java | 125 ++ ...licyAnnotatedInterfaceIntrospectorTestCase.java | 89 ++ .../introspect/WrapperStyleOperationTestCase.java | 74 + .../wsdl/xml/AbstractWSDLTestCase.java | 65 + .../sca/interfacedef/wsdl/xml/ReadTestCase.java | 77 + .../wsdl/xml/WSDLDocumentProcessorTestCase.java | 68 + .../sca/interfacedef/wsdl/xml/WSDLTestCase.java | 126 ++ .../sca/interfacedef/wsdl/xml/WriteTestCase.java | 82 + .../sca/interfacedef/wsdl/xml/Calculator.composite | 55 + .../wsdl/xml/CalculatorImpl.componentType | 33 + .../tuscany/sca/interfacedef/wsdl/xml/example.wsdl | 26 + .../interfacedef/wsdl/xml/invalid-stockquote.wsdl | 58 + .../tuscany/sca/interfacedef/wsdl/xml/ipo.xsd | 136 ++ .../sca/interfacedef/wsdl/xml/stockquote.wsdl | 58 + .../tuscany/sca/interfacedef/wsdl/xml/test1.wsdl | 45 + .../tuscany/sca/interfacedef/wsdl/xml/test1.xsd | 33 + .../tuscany/sca/interfacedef/wsdl/xml/test2.wsdl | 63 + .../wsdl/xml/unwrapped-stockquote.wsdl | 76 + .../test/resources/policy/stockquote_policy.wsdl | 62 + .../test/resources/wsdl/helloworld-interface.wsdl | 67 + .../test/resources/wsdl/helloworld-service.wsdl | 49 + .../src/test/resources/xsd/greeting.xsd | 29 + .../src/test/resources/xsd/helloworld.xsd | 22 + .../interface-wsdl/src/test/resources/xsd/name.xsd | 29 + branches/sca-java-2.0-M4/modules/launcher/LICENSE | 205 +++ .../modules/launcher/META-INF/MANIFEST.MF | 28 + branches/sca-java-2.0-M4/modules/launcher/NOTICE | 6 + branches/sca-java-2.0-M4/modules/launcher/pom.xml | 35 + .../apache/tuscany/sca/launcher/LauncherMain.java | 324 ++++ branches/sca-java-2.0-M4/modules/monitor/LICENSE | 205 +++ .../modules/monitor/META-INF/MANIFEST.MF | 15 + branches/sca-java-2.0-M4/modules/monitor/NOTICE | 6 + branches/sca-java-2.0-M4/modules/monitor/pom.xml | 33 + .../tuscany/sca/monitor/DefaultMonitorFactory.java | 60 + .../org/apache/tuscany/sca/monitor/Monitor.java | 342 ++++ .../apache/tuscany/sca/monitor/MonitorFactory.java | 61 + .../org/apache/tuscany/sca/monitor/Problem.java | 48 + .../tuscany/sca/monitor/impl/MonitorImpl.java | 144 ++ .../tuscany/sca/monitor/impl/ProblemImpl.java | 181 +++ .../org.apache.tuscany.sca.monitor.MonitorFactory | 18 + .../tuscany/sca/monitor/MonitorTestCase.java | 98 ++ .../tuscany-monitor-test-messages.properties | 24 + .../tuscany-monitor-test-messages_it.properties | 24 + branches/sca-java-2.0-M4/modules/myfaces/LICENSE | 241 +++ .../modules/myfaces/META-INF/MANIFEST.MF | 20 + branches/sca-java-2.0-M4/modules/myfaces/NOTICE | 12 + branches/sca-java-2.0-M4/modules/myfaces/pom.xml | 76 + .../TuscanyAnnotationLifecycleProvider.java | 69 + .../sca/myfaces/TuscanyAnnotationProcessor.java | 53 + branches/sca-java-2.0-M4/modules/node-api/LICENSE | 205 +++ .../modules/node-api/META-INF/MANIFEST.MF | 20 + branches/sca-java-2.0-M4/modules/node-api/NOTICE | 6 + branches/sca-java-2.0-M4/modules/node-api/pom.xml | 41 + .../java/org/apache/tuscany/sca/node/Client.java | 70 + .../org/apache/tuscany/sca/node/Contribution.java | 54 + .../sca/node/ContributionLocationHelper.java | 160 ++ .../java/org/apache/tuscany/sca/node/Node.java | 52 + .../org/apache/tuscany/sca/node/NodeFactory.java | 444 ++++++ .../org/apache/tuscany/sca/node/NodeFinder.java | 58 + .../org/apache/tuscany/sca/node/NodeMain2.java | 56 + .../node/configuration/BindingConfiguration.java | 55 + .../configuration/ContributionConfiguration.java | 102 ++ .../DefaultNodeConfigurationFactory.java | 46 + .../node/configuration/DeploymentComposite.java | 64 + .../sca/node/configuration/NodeConfiguration.java | 113 ++ .../configuration/NodeConfigurationFactory.java | 50 + .../impl/BindingConfigurationImpl.java | 54 + .../impl/ContributionConfigurationImpl.java | 155 ++ .../impl/DeploymentCompositeImpl.java | 64 + .../impl/NodeConfigurationFactoryImpl.java | 63 + .../configuration/impl/NodeConfigurationImpl.java | 186 +++ .../sca-java-2.0-M4/modules/node-impl-osgi/LICENSE | 205 +++ .../modules/node-impl-osgi/META-INF/MANIFEST.MF | 53 + .../sca-java-2.0-M4/modules/node-impl-osgi/NOTICE | 6 + .../sca-java-2.0-M4/modules/node-impl-osgi/pom.xml | 121 ++ .../tuscany/sca/node/osgi/impl/NodeActivator.java | 118 ++ .../tuscany/sca/node/osgi/impl/NodeManager.java | 143 ++ .../sca/node/osgi/impl/OSGiNodeFactoryImpl.java | 122 ++ .../remoteserviceadmin/EndpointDescription.java | 385 +++++ .../osgi/remoteserviceadmin/EndpointListener.java | 112 ++ .../remoteserviceadmin/EndpointPermission.java | 938 +++++++++++ .../remoteserviceadmin/ExportRegistration.java | 61 + .../remoteserviceadmin/ImportRegistration.java | 60 + .../osgi/remoteserviceadmin/RemoteConstants.java | 155 ++ .../remoteserviceadmin/RemoteServiceAdmin.java | 110 ++ .../RemoteServiceAdminEvent.java | 149 ++ .../RemoteServiceAdminListener.java | 16 + .../remoteserviceadmin/impl/EndpointHelper.java | 82 + .../impl/EndpointIntrospector.java | 494 ++++++ .../impl/ExportRegistrationImpl.java | 89 ++ .../impl/ImportRegistrationImpl.java | 92 ++ .../osgi/remoteserviceadmin/impl/OSGiHelper.java | 135 ++ .../impl/OSGiServiceExporter.java | 147 ++ .../impl/OSGiServiceImporter.java | 129 ++ .../impl/RemoteServiceAdminImpl.java | 252 +++ .../impl/TopologyManagerImpl.java | 389 +++++ .../discovery/impl/AbstractDiscoveryService.java | 280 ++++ .../sca/osgi/service/discovery/impl/Discovery.java | 66 + .../service/discovery/impl/DiscoveryActivator.java | 53 + .../discovery/impl/DomainDiscoveryService.java | 117 ++ .../discovery/impl/LocalDiscoveryService.java | 205 +++ .../org.apache.tuscany.sca.node.NodeFactory | 17 + .../java/calculator/dosgi/CalculatorService.java | 36 + .../calculator/dosgi/impl/CalculatorActivator.java | 75 + .../dosgi/impl/CalculatorServiceDSImpl.java | 114 ++ .../dosgi/impl/CalculatorServiceImpl.java | 96 ++ .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../dosgi/operations/impl/AddServiceImpl.java | 37 + .../dosgi/operations/impl/DivideServiceImpl.java | 37 + .../dosgi/operations/impl/MultiplyServiceImpl.java | 37 + .../dosgi/operations/impl/OperationsActivator.java | 88 ++ .../dosgi/operations/impl/SubtractServiceImpl.java | 37 + .../dosgi/test/CalculatorOSGiNodeTestCase.java | 156 ++ .../dosgi/test/CalculatorOSGiTestCase.java | 99 ++ .../calculator/dosgi/test/OSGiTestBundles.java | 361 +++++ .../calculator/dosgi/META-INF/MANIFEST.MF | 20 + .../calculator/dosgi/META-INF/sca-contribution.xml | 24 + .../dosgi/OSGI-INF/blueprint/calculator-module.xml | 43 + .../dosgi/OSGI-INF/calculator-component.xml | 36 + .../calculator-service-descriptions.xml | 67 + .../calculator/dosgi/bundle.componentType | 54 + .../calculator/dosgi/calculator.composite | 53 + .../dosgi/operations/META-INF/MANIFEST.MF | 22 + .../dosgi/operations/META-INF/sca-contribution.xml | 23 + .../dosgi/operations/OSGI-INF/add-component.xml | 25 + .../OSGI-INF/blueprint/operations-module.xml | 40 + .../dosgi/operations/OSGI-INF/divide-component.xml | 25 + .../operations/OSGI-INF/multiply-component.xml | 25 + .../operations/OSGI-INF/subtract-component.xml | 25 + .../dosgi/operations/bundle.componentType | 47 + .../dosgi/operations/operations.composite | 43 + .../calculator/dosgi/sca/META-INF/MANIFEST.MF | 12 + .../dosgi/sca/META-INF/sca-contribution.xml | 24 + .../dosgi/sca/OSGI-INF/sca/calculator.composite | 70 + branches/sca-java-2.0-M4/modules/node-impl/LICENSE | 205 +++ .../modules/node-impl/META-INF/MANIFEST.MF | 42 + branches/sca-java-2.0-M4/modules/node-impl/NOTICE | 6 + branches/sca-java-2.0-M4/modules/node-impl/pom.xml | 108 ++ .../xml/NodeConfigurationATOMProcessor.java | 160 ++ .../xml/NodeConfigurationProcessor.java | 236 +++ .../sca/node/impl/CompositeContextImpl.java | 71 + .../tuscany/sca/node/impl/NodeFactoryImpl.java | 395 +++++ .../org/apache/tuscany/sca/node/impl/NodeImpl.java | 369 +++++ .../org/apache/tuscany/sca/node/impl/NodeUtil.java | 43 + .../tuscany/sca/node/management/NodeManager.java | 65 + .../sca/node/management/NodeManagerMBean.java | 30 + ...ca.contribution.processor.StAXArtifactProcessor | 17 + .../org.apache.tuscany.sca.node.NodeFactory | 17 + ...sca.node.configuration.NodeConfigurationFactory | 17 + .../impl/node-impl-validation-messages.properties | 22 + .../node-impl/src/test/java/hello/HelloWorld.java | 30 + .../src/test/java/hello/HelloWorldImpl.java | 30 + .../xml/NodeConfigurationProcessorTestCase.java | 86 + .../tuscany/sca/node/impl/NodeImplTestCase.java | 107 ++ .../tuscany/sca/node/impl/NodeUtilTestCase.java | 39 + .../src/test/resources/HelloWorld.composite | 30 + .../test/resources/META-INF/sca-contribution.xml | 24 + .../tuscany/sca/node/configuration/node1.xml | 58 + .../modules/node-launcher-equinox/LICENSE | 205 +++ .../node-launcher-equinox/META-INF/MANIFEST.MF | 23 + .../modules/node-launcher-equinox/NOTICE | 6 + .../modules/node-launcher-equinox/pom.xml | 126 ++ .../sca/node/equinox/launcher/Contribution.java | 48 + .../launcher/ContributionLocationHelper.java | 66 + .../equinox/launcher/DomainManagerLauncher.java | 173 ++ .../sca/node/equinox/launcher/EquinoxHost.java | 650 ++++++++ .../node/equinox/launcher/FrameworkLauncher.java | 126 ++ .../node/equinox/launcher/LauncherException.java | 55 + .../node/equinox/launcher/NodeDaemonLauncher.java | 160 ++ .../sca/node/equinox/launcher/NodeLauncher.java | 376 +++++ .../sca/node/equinox/launcher/NodeLauncher2.java | 217 +++ .../node/equinox/launcher/NodeLauncherCommand.java | 57 + .../node/equinox/launcher/NodeLauncherUtil.java | 1345 ++++++++++++++++ .../sca/node/equinox/launcher/NodeMain.java | 62 + .../sca/node/equinox/launcher/J2SE-1.5.profile | 150 ++ .../sca/node/equinox/launcher/JavaSE-1.6.profile | 185 +++ .../sca/node/equinox/launcher/axiom-api-1.2.7.MF | 48 + .../node/equinox/launcher/axis2-kernel-1.4.1.MF | 2 + .../node/equinox/launcher/woden-impl-dom-1.0M8.MF | 229 +++ .../src/test/java/hello/HelloWorld.java | 30 + .../src/test/java/hello/HelloWorldClient.java | 50 + .../src/test/java/hello/HelloWorldImpl.java | 30 + .../equinox/launcher/EquinoxOSGiHostTestCase.java | 100 ++ .../equinox/launcher/NodeLauncherTestCase.java | 67 + .../src/test/resources/HelloWorld.composite | 34 + .../sca-java-2.0-M4/modules/node-launcher/LICENSE | 205 +++ .../modules/node-launcher/META-INF/MANIFEST.MF | 17 + .../sca-java-2.0-M4/modules/node-launcher/NOTICE | 6 + .../sca-java-2.0-M4/modules/node-launcher/pom.xml | 64 + .../tuscany/sca/node/launcher/Contribution.java | 48 + .../sca/node/launcher/DomainManagerLauncher.java | 180 +++ .../sca/node/launcher/LauncherException.java | 55 + .../sca/node/launcher/NodeDaemonLauncher.java | 169 ++ .../tuscany/sca/node/launcher/NodeLauncher.java | 303 ++++ .../sca/node/launcher/NodeLauncherUtil.java | 567 +++++++ .../apache/tuscany/sca/node/launcher/NodeMain.java | 62 + .../sca/node/launcher/NodeServletFilter.java | 130 ++ .../sca-java-2.0-M4/modules/policy-logging/LICENSE | 205 +++ .../modules/policy-logging/META-INF/MANIFEST.MF | 30 + .../sca-java-2.0-M4/modules/policy-logging/NOTICE | 6 + .../sca-java-2.0-M4/modules/policy-logging/pom.xml | 53 + .../apache/tuscany/sca/policy/logging/Logging.java | 46 + .../JDKLoggingImplementationPolicyProvider.java | 48 + .../sca/policy/logging/jdk/JDKLoggingPolicy.java | 97 ++ .../logging/jdk/JDKLoggingPolicyBuilder.java | 73 + .../logging/jdk/JDKLoggingPolicyInterceptor.java | 171 ++ .../logging/jdk/JDKLoggingPolicyProcessor.java | 135 ++ .../jdk/JDKLoggingPolicyProviderFactory.java | 68 + .../jdk/JDKLoggingReferencePolicyProvider.java | 45 + .../jdk/JDKLoggingServicePolicyProvider.java | 44 + ...ache.tuscany.sca.assembly.builder.PolicyBuilder | 17 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ....apache.tuscany.sca.definitions.xml.Definitions | 17 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 19 + .../tuscany/sca/policy/logging/definitions.xml | 30 + .../sca/policy/logging/jdk/PolicyReadTestCase.java | 94 ++ .../sca/policy/logging/jdk/mock_policies.xml | 23 + .../modules/policy-security/LICENSE | 205 +++ .../modules/policy-security/META-INF/MANIFEST.MF | 64 + .../sca-java-2.0-M4/modules/policy-security/NOTICE | 6 + .../modules/policy-security/pom.xml | 52 + .../basic/BasicAuthenticationPolicy.java | 65 + .../basic/BasicAuthenticationPolicyProcessor.java | 123 ++ .../BasicAuthenticationPolicyProviderFactory.java | 59 + .../basic/BasicAuthenticationPrincipal.java | 80 + ...icAuthenticationReferencePolicyInterceptor.java | 101 ++ ...BasicAuthenticationReferencePolicyProvider.java | 71 + ...asicAuthenticationServicePolicyInterceptor.java | 102 ++ .../BasicAuthenticationServicePolicyProvider.java | 71 + .../authentication/token/TokenPrincipal.java | 74 + .../policy/authorization/AuthorizationPolicy.java | 83 + .../AuthorizationPolicyProcessor.java | 150 ++ ...ityIdentityImplementationPolicyInterceptor.java | 83 + ...curityIdentityImplementationPolicyProvider.java | 89 ++ .../policy/identity/SecurityIdentityPolicy.java | 74 + .../identity/SecurityIdentityPolicyProcessor.java | 131 ++ .../SecurityIdentityPolicyProviderFactory.java | 56 + .../tuscany/sca/policy/security/SecurityUtil.java | 76 + ...AuthenticationImplementationPolicyProvider.java | 91 ++ .../jaas/JaasAuthenticationInterceptor.java | 81 + .../security/jaas/JaasAuthenticationPolicy.java | 71 + .../jaas/JaasAuthenticationPolicyHandler.java | 71 + .../jaas/JaasAuthenticationPolicyProcessor.java | 148 ++ .../JaasAuthenticationPolicyProviderFactory.java | 60 + ...ca.contribution.processor.StAXArtifactProcessor | 27 + ....apache.tuscany.sca.definitions.xml.Definitions | 18 + ...ache.tuscany.sca.provider.PolicyProviderFactory | 21 + .../tuscany/sca/policy/security/definitions.xml | 35 + .../sca/policy/security/tuscany_definitions.xml | 30 + .../policy-security-validation-messages.properties | 22 + .../policy/security/PolicyProcessorTestCase.java | 88 ++ .../policy/security/mock_policy_definitions.xml | 78 + .../sca-java-2.0-M4/modules/policy-xml-ws/LICENSE | 205 +++ .../modules/policy-xml-ws/META-INF/MANIFEST.MF | 31 + .../sca-java-2.0-M4/modules/policy-xml-ws/NOTICE | 6 + .../sca-java-2.0-M4/modules/policy-xml-ws/pom.xml | 130 ++ .../sca/policy/xml/ws/WSPolicyProcessor.java | 158 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + .../sca/policy/xml/ws/TestModelResolver.java | 64 + .../sca/policy/xml/ws/TestPolicyProcessor.java | 74 + .../policy/xml/ws/WSPolicyProcessorTestCase.java | 111 ++ .../tuscany/sca/policy/xml/test_definitions.xml | 106 ++ branches/sca-java-2.0-M4/modules/pom.xml | 166 ++ branches/sca-java-2.0-M4/modules/sca-api/LICENSE | 243 +++ .../modules/sca-api/META-INF/MANIFEST.MF | 18 + branches/sca-java-2.0-M4/modules/sca-api/NOTICE | 13 + branches/sca-java-2.0-M4/modules/sca-api/pom.xml | 35 + .../java/org/oasisopen/sca/ComponentContext.java | 122 ++ .../src/main/java/org/oasisopen/sca/Constants.java | 23 + .../org/oasisopen/sca/InvalidServiceException.java | 60 + .../org/oasisopen/sca/NoSuchDomainException.java | 40 + .../org/oasisopen/sca/NoSuchServiceException.java | 41 + .../java/org/oasisopen/sca/RequestContext.java | 55 + .../org/oasisopen/sca/SCARuntimeException.java | 41 + .../java/org/oasisopen/sca/ServiceReference.java | 22 + .../org/oasisopen/sca/ServiceRuntimeException.java | 58 + .../oasisopen/sca/ServiceUnavailableException.java | 54 + .../sca/annotation/AllowsPassByReference.java | 35 + .../oasisopen/sca/annotation/Authentication.java | 58 + .../oasisopen/sca/annotation/Authorization.java | 30 + .../org/oasisopen/sca/annotation/Callback.java | 39 + .../oasisopen/sca/annotation/ComponentName.java | 25 + .../oasisopen/sca/annotation/Confidentiality.java | 58 + .../org/oasisopen/sca/annotation/Constructor.java | 25 + .../java/org/oasisopen/sca/annotation/Context.java | 28 + .../java/org/oasisopen/sca/annotation/Destroy.java | 25 + .../org/oasisopen/sca/annotation/EagerInit.java | 25 + .../java/org/oasisopen/sca/annotation/Init.java | 26 + .../org/oasisopen/sca/annotation/Integrity.java | 58 + .../java/org/oasisopen/sca/annotation/Intent.java | 48 + .../sca/annotation/ManagedSharedTransaction.java | 29 + .../sca/annotation/ManagedTransaction.java | 40 + .../sca/annotation/MutualAuthentication.java | 30 + .../sca/annotation/NoManagedTransaction.java | 29 + .../java/org/oasisopen/sca/annotation/OneWay.java | 25 + .../org/oasisopen/sca/annotation/PolicySets.java | 35 + .../org/oasisopen/sca/annotation/Property.java | 38 + .../org/oasisopen/sca/annotation/Qualifier.java | 25 + .../org/oasisopen/sca/annotation/Reference.java | 40 + .../org/oasisopen/sca/annotation/Remotable.java | 26 + .../org/oasisopen/sca/annotation/Requires.java | 46 + .../java/org/oasisopen/sca/annotation/Scope.java | 36 + .../java/org/oasisopen/sca/annotation/Service.java | 45 + .../java/org/oasisopen/sca/client/SCAClient.java | 53 + .../org/oasisopen/sca/client/SCAClientFactory.java | 126 ++ .../sca/client/impl/SCAClientFactoryFinder.java | 241 +++ .../modules/sca-client-impl/LICENSE | 205 +++ .../modules/sca-client-impl/META-INF/MANIFEST.MF | 16 + .../sca-java-2.0-M4/modules/sca-client-impl/NOTICE | 6 + .../modules/sca-client-impl/pom.xml | 47 + .../sca/client/impl/SCAClientFactoryImpl.java | 59 + .../org.oasisopen.sca.client.SCAClientFactory | 1 + branches/sca-java-2.0-M4/modules/stripes/LICENSE | 241 +++ .../modules/stripes/META-INF/MANIFEST.MF | 31 + branches/sca-java-2.0-M4/modules/stripes/NOTICE | 12 + branches/sca-java-2.0-M4/modules/stripes/pom.xml | 60 + .../apache/tuscany/sca/stripes/TuscanyHelper.java | 298 ++++ .../tuscany/sca/stripes/TuscanyInterceptor.java | 73 + .../sca/stripes/TuscanyInterceptorSupport.java | 57 + branches/sca-java-2.0-M4/modules/wicket/LICENSE | 241 +++ .../modules/wicket/META-INF/MANIFEST.MF | 31 + branches/sca-java-2.0-M4/modules/wicket/NOTICE | 12 + branches/sca-java-2.0-M4/modules/wicket/pom.xml | 65 + .../apache/tuscany/sca/wicket/IContextLocator.java | 60 + .../sca/wicket/TuscanyComponentInjector.java | 158 ++ .../sca/wicket/TuscanyFieldValueFactory.java | 66 + .../apache/tuscany/sca/wicket/TuscanyInjector.java | 38 + branches/sca-java-2.0-M4/modules/xsd/LICENSE | 205 +++ .../modules/xsd/META-INF/MANIFEST.MF | 47 + branches/sca-java-2.0-M4/modules/xsd/NOTICE | 6 + branches/sca-java-2.0-M4/modules/xsd/pom.xml | 65 + .../apache/tuscany/sca/xsd/DefaultXSDFactory.java | 30 + .../org/apache/tuscany/sca/xsd/XSDFactory.java | 35 + .../org/apache/tuscany/sca/xsd/XSDefinition.java | 117 ++ .../tuscany/sca/xsd/impl/XSDFactoryImpl.java | 35 + .../tuscany/sca/xsd/impl/XSDefinitionImpl.java | 232 +++ .../tuscany/sca/xsd/xml/XSDDocumentProcessor.java | 106 ++ .../tuscany/sca/xsd/xml/XSDModelResolver.java | 328 ++++ ...sca.contribution.processor.URLArtifactProcessor | 19 + ...tuscany.sca.contribution.resolver.ModelResolver | 18 + .../services/org.apache.tuscany.sca.xsd.XSDFactory | 18 + .../xsd-xml-validation-messages.properties | 23 + .../sca/xsd/xml/XSDDocumentProcessorTestCase.java | 96 ++ .../xsd/src/test/resources/xsd/greeting.xsd | 29 + .../modules/xsd/src/test/resources/xsd/name.xsd | 29 + branches/sca-java-2.0-M4/pom.xml | 832 ++++++++++ branches/sca-java-2.0-M4/samples/README | 232 +++ .../samples/binding-ws-calculator/README | 97 ++ .../samples/binding-ws-calculator/build.xml | 67 + .../samples/binding-ws-calculator/calculator.png | Bin 0 -> 20552 bytes .../samples/binding-ws-calculator/calculator.svg | 329 ++++ .../samples/binding-ws-calculator/pom.xml | 89 ++ .../src/main/java/calculator/AddService.java | 31 + .../src/main/java/calculator/AddServiceImpl.java | 35 + .../main/java/calculator/CalculatorClientImpl.java | 66 + .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 70 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 + .../src/main/java/sample/SampleClient.java | 26 + .../src/main/java/sample/SampleClientImpl.java | 45 + .../src/main/resources/Calculator.composite | 59 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../test/java/calculator/CalculatorTestCase.java | 34 + branches/sca-java-2.0-M4/samples/build-common.xml | 102 ++ .../samples/calculator-equinox/README | 97 ++ .../samples/calculator-equinox/build.xml | 78 + .../samples/calculator-equinox/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator-equinox/calculator.svg | 329 ++++ .../samples/calculator-equinox/pom.xml | 84 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 + .../src/main/java/calculator/CalculatorClient.java | 62 + .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 70 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 + .../src/main/resources/Calculator.composite | 54 + .../test/java/calculator/CalculatorTestCase.java | 65 + .../samples/calculator-osgi/META-INF/MANIFEST.MF | 19 + .../sca-java-2.0-M4/samples/calculator-osgi/README | 97 ++ .../samples/calculator-osgi/build.xml | 78 + .../samples/calculator-osgi/pom.xml | 116 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 + .../main/java/calculator/CalculatorActivator.java | 54 + .../src/main/java/calculator/CalculatorClient.java | 52 + .../main/java/calculator/CalculatorService.java | 34 + .../java/calculator/CalculatorServiceImpl.java | 69 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 + .../src/main/resources/Calculator.composite | 54 + .../test/java/calculator/CalculatorTestCase.java | 55 + .../samples/calculator-rmi-reference/README | 138 ++ .../samples/calculator-rmi-reference/build.xml | 84 + .../calculator-rmi-reference.png | Bin 0 -> 23615 bytes .../calculator-rmi-reference.svg | 412 +++++ .../samples/calculator-rmi-reference/pom.xml | 82 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/CalculatorClient.java | 49 + .../main/java/calculator/CalculatorService.java | 39 + .../java/calculator/CalculatorServiceImpl.java | 68 + .../src/main/java/calculator/DivideService.java | 28 + .../src/main/java/calculator/MultiplyService.java | 28 + .../src/main/java/calculator/SubtractService.java | 28 + .../resources/CalculatorRMIReference.composite | 42 + .../calculator/CalculatorRMIReferenceTestCase.java | 70 + .../java/calculator/CalculatorRMIServiceImpl.java | 52 + .../samples/calculator-rmi-service/README | 147 ++ .../samples/calculator-rmi-service/build.xml | 76 + .../calculator-rmi-service.png | Bin 0 -> 20814 bytes .../calculator-rmi-service.svg | 330 ++++ .../samples/calculator-rmi-service/pom.xml | 67 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 30 + .../src/main/java/calculator/CalculatorClient.java | 40 + .../src/main/java/calculator/CalculatorServer.java | 45 + .../main/java/calculator/CalculatorService.java | 36 + .../java/calculator/CalculatorServiceImpl.java | 68 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 30 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 30 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../main/resources/CalculatorRMIServer.composite | 53 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../calculator/CalculatorRMIServerTestCase.java | 63 + branches/sca-java-2.0-M4/samples/calculator/README | 97 ++ .../sca-java-2.0-M4/samples/calculator/build.xml | 65 + .../samples/calculator/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator/calculator.svg | 329 ++++ .../sca-java-2.0-M4/samples/calculator/pom.xml | 78 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 38 + .../src/main/java/calculator/CalculatorClient.java | 48 + .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 72 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 38 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 38 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 38 + .../src/main/resources/Calculator.composite | 49 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../test/java/calculator/CalculatorTestCase.java | 63 + .../samples/dosgi-calculator-operations/LICENSE | 205 +++ .../META-INF/MANIFEST.MF | 22 + .../samples/dosgi-calculator-operations/NOTICE | 6 + .../OSGI-INF/add-component.xml | 25 + .../OSGI-INF/blueprint/operations-module.xml | 40 + .../OSGI-INF/divide-component.xml | 25 + .../OSGI-INF/multiply-component.xml | 25 + .../OSGI-INF/sca/bundle.componentType | 47 + .../OSGI-INF/sca/bundle.composite | 43 + .../OSGI-INF/subtract-component.xml | 25 + .../samples/dosgi-calculator-operations/README | 183 +++ .../samples/dosgi-calculator-operations/pom.xml | 141 ++ .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../dosgi/operations/impl/AddServiceImpl.java | 37 + .../dosgi/operations/impl/DivideServiceImpl.java | 37 + .../dosgi/operations/impl/MultiplyServiceImpl.java | 37 + .../dosgi/operations/impl/OperationsActivator.java | 88 ++ .../dosgi/operations/impl/SubtractServiceImpl.java | 37 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../dosgi/operations/test/OSGiTestUtils.java | 105 ++ .../dosgi/operations/test/OperationsNode.java | 43 + .../test/OperationsOSGiNodeTestCase.java | 104 ++ .../samples/dosgi-calculator/LICENSE | 205 +++ .../samples/dosgi-calculator/META-INF/MANIFEST.MF | 20 + .../samples/dosgi-calculator/NOTICE | 6 + .../OSGI-INF/blueprint/calculator-module.xml | 43 + .../OSGI-INF/calculator-component.xml | 36 + .../OSGI-INF/sca/bundle.componentType | 54 + .../dosgi-calculator/OSGI-INF/sca/bundle.composite | 45 + .../samples/dosgi-calculator/README | 155 ++ .../samples/dosgi-calculator/dosgi-calculator.png | Bin 0 -> 85103 bytes .../samples/dosgi-calculator/pom.xml | 153 ++ .../java/calculator/dosgi/CalculatorService.java | 36 + .../calculator/dosgi/impl/CalculatorActivator.java | 76 + .../dosgi/impl/CalculatorServiceDSImpl.java | 114 ++ .../dosgi/impl/CalculatorServiceImpl.java | 105 ++ .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../java/calculator/rmi/OperationsRMIServer.java | 93 ++ .../calculator/rmi/OperationsRMIServer_Stub.java | 132 ++ .../main/java/calculator/rmi/OperationsRemote.java | 37 + .../main/resources/META-INF/sca-contribution.xml | 24 + .../java/calculator/dosgi/test/CalculatorNode.java | 43 + .../dosgi/test/CalculatorOSGiNodeTestCase.java | 144 ++ .../java/calculator/dosgi/test/OSGiTestUtils.java | 105 ++ .../dosgi-dynamic-calculator-operations/LICENSE | 205 +++ .../META-INF/MANIFEST.MF | 23 + .../dosgi-dynamic-calculator-operations/NOTICE | 6 + .../OSGI-INF/add-component.xml | 25 + .../OSGI-INF/blueprint/operations-module.xml | 40 + .../OSGI-INF/divide-component.xml | 25 + .../OSGI-INF/multiply-component.xml | 25 + .../OSGI-INF/sca-config/operations-config.xml | 29 + .../OSGI-INF/subtract-component.xml | 25 + .../dosgi-dynamic-calculator-operations/README | 183 +++ .../dosgi-dynamic-calculator-operations/pom.xml | 141 ++ .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../dosgi/operations/impl/AddServiceImpl.java | 37 + .../dosgi/operations/impl/DivideServiceImpl.java | 37 + .../dosgi/operations/impl/MultiplyServiceImpl.java | 37 + .../dosgi/operations/impl/OperationsActivator.java | 94 ++ .../dosgi/operations/impl/SubtractServiceImpl.java | 37 + .../dosgi/operations/test/OSGiTestUtils.java | 105 ++ .../dosgi/operations/test/OperationsNode.java | 43 + .../test/OperationsOSGiNodeTestCase.java | 104 ++ .../samples/dosgi-dynamic-calculator/LICENSE | 205 +++ .../dosgi-dynamic-calculator/META-INF/MANIFEST.MF | 23 + .../samples/dosgi-dynamic-calculator/NOTICE | 6 + .../OSGI-INF/blueprint/calculator-module.xml | 43 + .../OSGI-INF/calculator-component.xml | 36 + .../calculator-service-descriptions.xml | 61 + .../OSGI-INF/sca-config/calculator-config.xml | 32 + .../samples/dosgi-dynamic-calculator/README | 155 ++ .../dosgi-dynamic-calculator/dosgi-calculator.png | Bin 0 -> 85103 bytes .../samples/dosgi-dynamic-calculator/pom.xml | 146 ++ .../java/calculator/dosgi/CalculatorService.java | 36 + .../calculator/dosgi/impl/CalculatorActivator.java | 78 + .../dosgi/impl/CalculatorServiceDSImpl.java | 114 ++ .../dosgi/impl/CalculatorServiceImpl.java | 105 ++ .../calculator/dosgi/operations/AddService.java | 31 + .../calculator/dosgi/operations/DivideService.java | 31 + .../dosgi/operations/MultiplyService.java | 31 + .../dosgi/operations/SubtractService.java | 31 + .../java/calculator/rmi/OperationsRMIServer.java | 93 ++ .../calculator/rmi/OperationsRMIServer_Stub.java | 132 ++ .../main/java/calculator/rmi/OperationsRemote.java | 37 + .../java/calculator/dosgi/test/CalculatorNode.java | 43 + .../dosgi/test/CalculatorOSGiNodeTestCase.java | 144 ++ .../java/calculator/dosgi/test/OSGiTestUtils.java | 105 ++ .../sca-java-2.0-M4/samples/helloworld-bpel/README | 151 ++ .../samples/helloworld-bpel/build.xml | 95 ++ .../samples/helloworld-bpel/helloworld-bpel.png | Bin 0 -> 8897 bytes .../samples/helloworld-bpel/helloworld-bpel.svg | 179 +++ .../samples/helloworld-bpel/pom.xml | 115 ++ .../src/main/java/helloworld/BPELClient.java | 45 + .../src/main/java/helloworld/Hello.java | 29 + .../main/resources/META-INF/sca-contribution.xml | 23 + .../src/main/resources/helloworld.bpel | 78 + .../src/main/resources/helloworld.composite | 29 + .../src/main/resources/helloworld.wsdl | 82 + .../src/main/resources/log4j.properties | 35 + .../java/helloworld/BPELHelloWorldTestCase.java | 65 + .../samples/implementation-java-calculator/README | 96 ++ .../implementation-java-calculator/build.xml | 59 + .../implementation-java-calculator/calculator.png | Bin 0 -> 20552 bytes .../implementation-java-calculator/calculator.svg | 329 ++++ .../samples/implementation-java-calculator/pom.xml | 65 + .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 35 + .../src/main/java/calculator/CalculatorClient.java | 62 + .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 70 + .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 35 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 35 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 35 + .../src/main/resources/Calculator.composite | 54 + .../test/java/calculator/CalculatorTestCase.java | 73 + .../sca-java-2.0-M4/samples/logging.properties | 25 + branches/sca-java-2.0-M4/samples/pom.xml | 78 + .../samples/webapps/helloworld-bpel/pom.xml | 130 ++ .../src/main/java/sample/HelloworldService.java | 28 + .../src/main/resources/helloworld.bpel | 66 + .../src/main/resources/helloworld.wsdl | 82 + .../src/main/webapp/WEB-INF/web.composite | 37 + .../src/main/webapp/WEB-INF/web.xml | 41 + .../helloworld-bpel/src/main/webapp/hello.jsp | 36 + .../samples/webapps/helloworld-jms/README | 131 ++ .../samples/webapps/helloworld-jms/pom.xml | 80 + .../src/main/java/sample/HelloWorldClient.java | 37 + .../src/main/java/sample/HelloWorldService.java | 29 + .../main/java/sample/HelloWorldServiceImpl.java | 31 + .../src/main/webapp/META-INF/context.xml | 34 + .../src/main/webapp/WEB-INF/jetty-env.xml | 48 + .../src/main/webapp/WEB-INF/web.composite | 44 + .../helloworld-jms/src/main/webapp/WEB-INF/web.xml | 66 + .../helloworld-jms/src/main/webapp/hello.jsp | 41 + .../samples/webapps/helloworld-js-client/pom.xml | 62 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 28 + .../src/main/webapp/WEB-INF/web.composite | 36 + .../src/main/webapp/WEB-INF/web.xml | 41 + .../src/main/webapp/hello.html | 51 + .../samples/webapps/helloworld-jsf/pom.xml | 62 + .../src/main/java/sample/HelloWorldController.java | 56 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 27 + .../src/main/webapp/WEB-INF/faces-config.xml | 51 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../helloworld-jsf/src/main/webapp/WEB-INF/web.xml | 191 +++ .../helloworld-jsf/src/main/webapp/helloWorld.jsp | 40 + .../helloworld-jsf/src/main/webapp/index.jsp | 23 + .../helloworld-jsf/src/main/webapp/page2.jsp | 38 + .../samples/webapps/helloworld-jsp/pom.xml | 55 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 28 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../helloworld-jsp/src/main/webapp/WEB-INF/web.xml | 41 + .../helloworld-jsp/src/main/webapp/hello.jsp | 37 + .../samples/webapps/helloworld-rest/README | 37 + .../samples/webapps/helloworld-rest/pom.xml | 111 ++ .../java/helloworldrest/ClientJavaTestService.java | 29 + .../helloworldrest/ClientTestServiceWebapp.java | 108 ++ .../java/helloworldrest/HelloWorldService.java | 13 + .../java/helloworldrest/HelloWorldServiceImpl.java | 44 + .../src/main/resources/rest.composite | 37 + .../src/main/webapp/HelloWorldJSONRPC.html | 75 + .../src/main/webapp/META-INF/sca-contribution.xml | 26 + .../src/main/webapp/WEB-INF/web.xml | 35 + .../helloworld-rest/src/main/webapp/style.css | 22 + .../helloworld-rest/target/classes/rest.composite | 37 + .../samples/webapps/helloworld-servlet/pom.xml | 61 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 27 + .../src/main/java/sample/HelloworldServlet.java | 64 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../src/main/webapp/WEB-INF/web.xml | 44 + .../helloworld-servlet/src/main/webapp/hello.html | 46 + .../samples/webapps/helloworld-stripes/pom.xml | 65 + .../main/java/mystripes/action/BaseActionBean.java | 33 + .../main/java/mystripes/action/HomeActionBean.java | 45 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 28 + .../src/main/resources/StripesResources.properties | 57 + .../src/main/resources/log4j.properties | 31 + .../src/main/webapp/WEB-INF/jsp/home.jsp | 26 + .../src/main/webapp/WEB-INF/jsp/layout.jsp | 39 + .../src/main/webapp/WEB-INF/jsp/taglibs.jsp | 29 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../src/main/webapp/WEB-INF/web.xml | 61 + .../helloworld-stripes/src/main/webapp/index.html | 24 + .../samples/webapps/helloworld-wicket/pom.xml | 76 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 28 + .../src/main/java/sample/wicket/HomePage.html | 48 + .../src/main/java/sample/wicket/HomePage.java | 66 + .../src/main/java/sample/wicket/IMyService.java | 35 + .../src/main/java/sample/wicket/MyService.java | 38 + .../main/java/sample/wicket/WicketApplication.java | 47 + .../src/main/resources/log4j.properties | 29 + .../src/main/webapp/WEB-INF/web.composite | 34 + .../src/main/webapp/WEB-INF/web.xml | 50 + .../samples/webapps/helloworld/pom.xml | 55 + .../src/main/java/sample/HelloworldService.java | 25 + .../main/java/sample/HelloworldServiceImpl.java | 38 + .../src/main/webapp/WEB-INF/web.composite | 29 + .../helloworld/src/main/webapp/WEB-INF/web.xml | 37 + 3925 files changed, 341116 insertions(+) create mode 100644 branches/sca-java-2.0-M4/BUILDING create mode 100644 branches/sca-java-2.0-M4/CHANGES create mode 100644 branches/sca-java-2.0-M4/LICENSE create mode 100644 branches/sca-java-2.0-M4/NOTICE create mode 100644 branches/sca-java-2.0-M4/README create mode 100644 branches/sca-java-2.0-M4/RELEASE_NOTES create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/distribution/all/manifests/axiom-api-1.2.7.MF create mode 100644 branches/sca-java-2.0-M4/distribution/all/manifests/woden-impl-dom-1.0M8.MF create mode 100644 branches/sca-java-2.0-M4/distribution/all/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/assembly/bin.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/assembly/src.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-common.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-launcher.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-modules.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-samples.xml create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/INSTALL create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/LICENSE create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/NOTICE create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/README create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/default.config create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/osgi.config create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.bat create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.sh create mode 100644 branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/unmanaged.config create mode 100644 branches/sca-java-2.0-M4/distribution/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/README.txt create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/download-tomcat/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/testing/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/LICENSE create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/NOTICE create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/Installer.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/pom.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/assembly/war.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp create mode 100644 branches/sca-java-2.0-M4/features/all/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/api/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/core/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/ejava/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/process/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/web20/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/webapp/pom.xml create mode 100644 branches/sca-java-2.0-M4/features/webservice/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/itest/bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/service3.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/service3.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenarios.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenarios.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenarios.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenarios.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9a.composite create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java create mode 100644 branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/CallBackApiTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/CallBackBasicTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/component-type/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar create mode 100644 branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository3/contribution.zip create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/hello.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/store.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-import-export/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-zip/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/contribution-zip/src/test/resources/repository/contribution.zip create mode 100644 branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/build.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/build.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/build.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/build.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/legal-checks/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/EndpointsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/Utils.java create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/nested.composite create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/main/resources/ExceptionTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReference.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InterfacesTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite create mode 100644 branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuote.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuoteImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jaxws/src/test/resources/StockQuote.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/selectors/selectors.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/tempq.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions/definitions.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/exceptions/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/nulls.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/properties/properties.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/client.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/selectors/selectors.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsClient.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsService.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/ttl.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/jndi.properties create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/service.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite create mode 100644 branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite create mode 100644 branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml create mode 100644 branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/src/main/resources/OperationOverload.composite create mode 100644 branches/sca-java-2.0-M4/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/resources/Customer.composite create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/resources/LoggingMessages.properties create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/definitions.xml create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/main/resources/Payment.composite create mode 100644 branches/sca-java-2.0-M4/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/properties/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/package-info.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/ConstructorPropertyInjection.composite create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/Outer.composite create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/OuterPropertyTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/PropertyTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/customer.xsd create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/fileProperty.txt create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/manyValuesFileProperty.txt create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/mySimpleService.composite create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcProps.txt create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcprops.xsd create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite create mode 100644 branches/sca-java-2.0-M4/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/references/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/resources/AutoWiredReferencesTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/resources/InnerReferencesTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/references/src/main/resources/ManualWiredReferencesTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/Helloworld.composite create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/scdl/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/scdl/src/test/resources/test.composite create mode 100644 branches/sca-java-2.0-M4/itest/scopes/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java create mode 100644 branches/sca-java-2.0-M4/itest/scopes/src/main/resources/scopes.composite create mode 100644 branches/sca-java-2.0-M4/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeA/CompositeA.composite create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeB/CompositeB.composite create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/services/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/itest/services/src/main/resources/ServicesTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java create mode 100644 branches/sca-java-2.0-M4/itest/wires/pom.xml create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/main/resources/WireTest.composite create mode 100644 branches/sca-java-2.0-M4/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd create mode 100644 branches/sca-java-2.0-M4/modules/assembly/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/assembly/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/assembly/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/assembly/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/Customer.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/resources/account/account.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/content/test.html create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/test.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/testCache.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/client.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/service.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/jquery.html create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/package-info.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/builder/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/builder/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png create mode 100644 branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/common-java/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/common-java/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java create mode 100644 branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/XMLStreamSerializer.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DOMXmlNodeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/DelegatingNamespaceContext.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValueArrayStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NameValuePairStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamedProperty.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NamespaceContextImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/NilElementStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/SimpleXmlNodeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/WrappingXMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLDocumentStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLFragmentStreamReaderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XMLStreamable.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNode.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlNodeIterator.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XMLCharHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/dom/DOMHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/StAXHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/stax/reader/XmlTreeStreamReaderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/java/org/apache/tuscany/sca/common/xml/xpath/XPathHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/common-xml/src/test/resources/org/apache/tuscany/sca/common/xml/stax/test.xsd create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/BundleReference.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleContributionScanner.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiBundleReferenceModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/java/org/apache/tuscany/sca/contribution/osgi/impl/OSGiClassReferenceModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/contribution-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScanner create mode 100644 branches/sca-java-2.0-M4/modules/contribution/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/contribution/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/contribution/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/contribution/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Artifact.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContentType.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Contribution.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/ContributionMetadata.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultContributionFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultExport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/DefaultImport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Export.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/Import.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/PackageType.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ArtifactImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/ContributionMetadataImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultExportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/impl/DefaultImportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/DefaultJavaImportExportFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaExport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/JavaImportExportFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ClassLoaderModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoader.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportExportFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/DefaultNamespaceImportExportFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceExport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImport.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/NamespaceImportExportFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportExportFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/BaseStAXArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidatingXMLInputFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultValidationSchemaExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtendedURLArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ProcessorContext.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLInputFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidatingXMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ValidationSchemaExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/impl/ContributionContentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyAttributeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/xml/AnyElementProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScannerExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/DirectoryContributionScanner.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/impl/JarContributionScanner.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionGeneratedMetadataDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.ContributionFactory create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.java.JavaImportExportFactory create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.namespace.NamespaceImportExportFactory create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessor create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXAttributeProcessorExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchemaExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/contribution-java-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/contribution-namespace-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/contribution-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/ContributionClassLoaderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaExportProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/java/impl/JavaImportProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceExportProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/namespace/impl/NamespaceImportProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/resources/deployables/sample-calculator.jar create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/resources/repository/sample-calculator.jar create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/resources/test.composite create mode 100644 branches/sca-java-2.0-M4/modules/contribution/src/test/resources/test.ext create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/DataBindingJavaInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/processor/WrapperJavaInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Array2ArrayTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Exception2ExceptionTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Input2InputTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/transformers/Output2OutputTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataBindingRuntimeWireProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/DataTransformationInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/java/org/apache/tuscany/sca/core/databinding/wire/PassByValueInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor create mode 100644 branches/sca-java-2.0-M4/modules/core-databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/doc/Context Model.emx create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ComponentContextFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ContextFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/PropertyValueFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/RequestContextFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/DataExchangeSemantics.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Interceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Invoker.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Message.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/MessageFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/Phase.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/PhasedInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ConfigAttributes.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/management/ManagementService.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderRRB.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProviderRRB.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProviderRRB.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DefaultWireProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/DomainRegistryFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointListener.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointReferenceBinder.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ReferenceParameters.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponent.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentReference.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentService.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeEndpointReference.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWire.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeWireProcessorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/NotificationListener.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkScheduler.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/java/org/apache/tuscany/sca/work/WorkSchedulerException.java create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ContextFactoryExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.endpointresolver.EndpointResolverFactoryExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/core-spi/src/test/java/org/apache/tuscany/sca/context/DefaultContextFactoryExtensionPointTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/core/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/core/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/core/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/RuntimeAssemblyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointRegistryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParameterProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/ReferenceParametersImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultComponentContextFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/DefaultRequestContextFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/InstanceWrapper.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectCreationException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/factory/ObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackInterfaceInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/DefaultProxyFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyCreationException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncJDKInvocationHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/AsyncResponse.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/MessageImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/NoMethodForOperationException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorter.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/DefaultDomainRegistryFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/AbstractScopeContainer.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/Scope.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainer.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeContainerFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopeRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/ScopedRuntimeComponent.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetDestructionException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetInitializationException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetNotFoundException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/TargetResolutionException.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainer.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/CompositeScopeContainerFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ScopeRegistryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainer.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/StatelessScopeContainerFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/DefaultWorkScheduler.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManager.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/Work.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkEvent.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkItem.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/java/org/apache/tuscany/sca/core/work/impl/WorkListener.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.ComponentContextFactory create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.RequestContextFactory create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.scope.ScopeRegistry create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.invocation.MessageFactory create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.DomainRegistryFactory create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointReferenceBinder create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.work.WorkScheduler create mode 100644 branches/sca-java-2.0-M4/modules/core/src/main/resources/endpoint-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManagerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/invocation/impl/PhaseSorterTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/FailingWork.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyFailingRunnable.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnable.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/JSR237MyRunnerListener.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/Jsr237WorkSchedulerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TestWorkListener.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/ThreadPoolWorkManagerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/core/work/impl/TimeDelayWork.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/java/org/apache/tuscany/sca/scope/ScopeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/core/src/test/resources/META-INF/services/org.apache.tuscany.sca.invocation.PhaseTest create mode 100644 branches/sca-java-2.0-M4/modules/data-api/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/data-api/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/data-api/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/data-api/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Collection.java create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Entry.java create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/Item.java create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/ItemCollection.java create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/LocalItemCollection.java create mode 100644 branches/sca-java-2.0-M4/modules/data-api/src/main/java/org/apache/tuscany/sca/data/collection/NotFoundException.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/AxiomHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Exception2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Externalizable2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Exception.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Externalizable.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2Object.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2String.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElement2XMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/OMElementWrapperHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/Object2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/String2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/java/org/apache/tuscany/sca/databinding/axiom/XMLStreamReader2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/test/java/org/apache/tuscany/sca/databinding/axiom/OMElementTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/test/resources/ipo.xml create mode 100755 branches/sca-java-2.0-M4/modules/databinding-axiom/src/test/resources/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/databinding-axiom/src/test/resources/order.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/AxiomHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXB2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/JAXBDataSource.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/OMElement2JAXB.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBCustomBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDSContext.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/JAXBDataSourceExt.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/SourceDataSource.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStreamWriterWithOS.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/java/org/apache/tuscany/sca/databinding/jaxb/axiom/ext/XMLStringDataSource.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/JAXB2OMTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/test/java/org/apache/tuscany/databinding/jaxb/axiom/OMElement2JAXBTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb-axiom/src/test/resources/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/AnyTypeXmlAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DOMElementXmlAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DataConverter.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/DefaultXMLAdapterExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXB2String.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBPropertyDescriptor.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTypeHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperException.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Node2JAXB.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/Reader2JAXB.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/String2JAXB.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLAdapterExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLRootElementUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/XMLStreamReader2JAXB.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.jaxb.XMLAdapterExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/com/example/stock/StockQuoteOffer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCacheTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBDataBindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBReflectionTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/JAXBWrapperHandlerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyBean.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyInterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MyJaxbBean.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/MySubBean.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java create mode 100755 branches/sca-java-2.0-M4/modules/databinding-jaxb/src/test/resources/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2JavaBean.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2String.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSON2XMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JSONHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSON.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONObject.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/String2JSON.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/XMLStreamReader2JSON.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSON2OMElement.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONBadgerfishDataSource.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/java/org/apache/tuscany/sca/databinding/json/axiom/JSONDataSource.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JSONTransformerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/JavaBean2JSONTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyBean.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/MyInterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/java/org/apache/tuscany/sca/databinding/json/POJOTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding-json/src/test/resources/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/databinding/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/databinding/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/databinding/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/databinding/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataBindingExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipe.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DataPipeTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultDataBindingExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/DefaultTransformerExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Mediator.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PullTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/PushTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/SimpleTypeMapper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationContext.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformationException.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/Transformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/TransformerExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/WrapperHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/XMLTypeHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/annotation/DataType.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/externalizable/ExternalizableDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/BaseTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/DirectedGraph.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Group2GroupTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/GroupDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/Java2SimpleTypeTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/MediatorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/PipedTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleType2JavaTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/SimpleTypeMapperImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/TransformationContextImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/impl/XSDDataTypeConverter.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/DOMNode2JavaBeanTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/Java2XMLMapperException.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2DOMNodeTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLStreamReaderTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBean2XMLTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaBeansDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/JavaExceptionDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/SimpleJavaDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaBeanTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/javabeans/XML2JavaMapperException.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/DataTypeHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/util/LRUCache.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/DOMWrapperHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputSource2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/InputStream2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2OutputStream.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SimpleJavaType.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2SourceTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2String.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2Writer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Node2XMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Reader2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SAX2DOMPipe.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/SimpleJavaType2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2NodeTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2ResultTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Source2StringTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StAXDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/StreamDataPipe.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2SourceTransformer.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/String2XMLStreamReader.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/Writer2ReaderDataPipe.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLGroupDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2Node.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2SAX.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStreamReader2String.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/java/org/apache/tuscany/sca/databinding/xml/XMLStringDataBinding.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBinding create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.DataBindingExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.Mediator create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PullTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.PushTransformer create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.SimpleTypeMapper create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/main/resources/META-INF/services/org.apache.tuscany.sca.databinding.TransformerExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/DataBindingExtensionTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/SimpleTypeMapperExtensionTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/TransformerExtensionTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/extension/XSDDataTypeConverterTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DataBindingTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/DirectedGraphTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/MediatorImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/impl/XMLDocumentStreamReaderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/BeanXMLStreamReaderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DOM2StAXTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/DataPipeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/JavaBean2XMLStreamReaderTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/Node2StringTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/PushTransformationTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/java/org/apache/tuscany/sca/databinding/xml/TraxTransformerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/impl/order.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/databinding/src/test/resources/org/apache/tuscany/sca/databinding/xml/foo.xml create mode 100644 branches/sca-java-2.0-M4/modules/deployment/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/deployment/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/deployment/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/deployment/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/DefaultDeployer.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/Contributions.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/resources/META-INF/services/org.apache.tuscany.sca.deployment.Deployer create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/main/resources/org/apache/tuscany/sca/deployment/impl/deployer-impl-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/test/java/hello/deployer/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/test/java/hello/deployer/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/test/java/org/apache/tuscany/sca/deployment/impl/DeployerImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/test/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/deployment/src/test/resources/org/apache/tuscany/sca/deployment/impl/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/ConfigAttributesImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNode.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/main/java/org/apache/tuscany/sca/domain/node/DomainNodeMain.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/java/itest/nodes/Helloworld.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/ConfigTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/OneNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/StopStartNodesTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/resources/itest-nodes-helloworld-client-2.0-SNAPSHOT.jar create mode 100644 branches/sca-java-2.0-M4/modules/domain-node/src/test/resources/itest-nodes-helloworld-service-2.0-SNAPSHOT.jar create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/README create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/TODO create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/src/main/java/org/apache/tuscany/sca/endpoint/dht/OverlayEndpointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-dht/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/AbstractReplicatedMap.java create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/MapStore.java create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedMap.java create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointRegistry create mode 100644 branches/sca-java-2.0-M4/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoverer.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscoveryActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxHostTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/EquinoxServiceDiscovererTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/test/java/org/apache/tuscany/sca/extensibility/equinox/TestEquinoxHost.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility-equinox/src/test/resources/test-bundle.jar create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ExtensionPointRegistry.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/FactoryExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/LifeCycleListener.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivatorExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscoverer.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclaration.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDeclarationParser.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscoverer.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/InvalidSyntaxException.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/impl/LDAPFilter.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.FactoryExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.UtilityExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ContextClassLoaderServiceDiscovererTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultExtensionPointRegistryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/DefaultUtilityExtensionPointTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceDiscoveryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/ServiceHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/DummyImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/Test2Impl.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/java/org/apache/tuscany/sca/extensibility/test/TestInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/extensibility/src/test/resources/META-INF/services/org.apache.tuscany.sca.extensibility.test.TestInterface create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/HttpServiceWrapper.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/OSGiServletHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/main/java/org/apache/tuscany/sca/http/osgi/ServletRequestDispatcher.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/test/java/org/apache/tuscany/sca/http/osgi/OSGiServletHostTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/test/resources/content/test.html create mode 100644 branches/sca-java-2.0-M4/modules/host-http-osgi/src/test/resources/tuscany.keyStore create mode 100644 branches/sca-java-2.0-M4/modules/host-http/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-http/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-http/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-http/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultResourceServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/DefaultServletHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ExtensibleServletHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/java/org/apache/tuscany/sca/host/http/ServletMappingException.java create mode 100644 branches/sca-java-2.0-M4/modules/host-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHostExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyDefaultServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyLogger.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/main/java/org/apache/tuscany/sca/http/jetty/JettyServer.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/test/resources/content/test.html create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty/src/test/resources/tuscany.keyStore create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyDefaultServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/main/java/org/apache/tuscany/sca/http/jetty7/JettyServer.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/test/java/org/apache/tuscany/sca/http/jetty7/JettyServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/test/resources/content/test.html create mode 100644 branches/sca-java-2.0-M4/modules/host-jetty7/src/test/resources/tuscany.keyStore create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/DefaultRMIHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/ExtensibleRMIHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostException.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostExtensionPoint.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMIHostRuntimeException.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/java/org/apache/tuscany/sca/host/rmi/RMISocketFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.rmi.RMIHostExtensionPoint create mode 100644 branches/sca-java-2.0-M4/modules/host-rmi/src/test/java/org/apache/tuscany/sca/host/rmi/RMIHostImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/ServletHostHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppRequestDispatcher.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppServletHost.java create mode 100644 branches/sca-java-2.0-M4/modules/host-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.host.http.ServletHost create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/BPELODEDeployFile.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/DeploymentWorkspace.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServer.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/GeronimoTxFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeployment.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEDeploymentException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEndpointReference.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEEprContext.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEInitializationException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEShutdownException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyEPR.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyPRC.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/TuscanyProcessConfImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/ODEInvocationException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/java/org/apache/tuscany/sca/implementation/bpel/ode/EmbeddedODEServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/resources/helloworld/deploy.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/resources/helloworld/greetings.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/resources/helloworld/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel-runtime/src/test/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELProcessDefinition.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImplementationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELImportElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELPartnerLinkTypeElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/xml/BPELProcessorConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.bpel.BPELFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/main/resources/impl-bpel-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELDocumentProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/test/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementationProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/test/resources/helloworld/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/modules/implementation-bpel/src/test/resources/helloworld/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.context.PropertyValueFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.RuntimeWireProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/main/resources/org/apache/tuscany/sca/implementation/java/definitions/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapperTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/CallbackWireObjectFactoryTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjectorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactoryTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodEventInvokerTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjectorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactoryTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/SingletonObjectFactoryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/injection/TestObjectFactoryTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean1.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Bean2.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/Entry.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/JavaIntrospectionHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/util/SuperBean.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/BaseJavaImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/IntrospectionException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaConstructorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaElementImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaParameterImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaResourceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaScopeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaClassIntrospectorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaClassVisitor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/JavaIntrospectionHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AmbiguousConstructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateConstructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateDestructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateInitException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicatePropertyException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateReferenceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DuplicateResourceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalCallbackReferenceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalContextException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalDestructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalInitException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalPropertyException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalReferenceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalResourceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementationException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceTypeException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceTypeNotFoundException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/UnknownContextTypeException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.JavaImplementationFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorPropertyTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorResourceTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicConstructorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeutisticExtensibleConstructorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ModelHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceCallbackTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/TestModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-java/src/test/resources/org/apache/tuscany/sca/implementation/java/xml/definitions_with_policysets.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiDistributionProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiImplementationRuntimeActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/java/org/apache/tuscany/sca/implementation/osgi/runtime/OSGiTargetInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi-runtime/src/main/resources/impl-osgi-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/LICENSE create mode 100755 branches/sca-java-2.0-M4/modules/implementation-osgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultServiceDescriptionsFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiProperty.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/SCAConfig.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescription.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptions.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/ServiceDescriptionsFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiPropertyImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/SCAConfigImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/ServiceDescriptionsImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiImplementationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiPropertyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/SCAConfigProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.osgi.ServiceDescriptionsFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/main/resources/impl-osgi-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/BluePrintComponentsProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiComponentProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/OSGiReadImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/ServiceDescriptionsTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/java/org/apache/tuscany/sca/implementation/osgi/xml/TestModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/calculator-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/OSGI-INF/sca/bundle.componentType create mode 100644 branches/sca-java-2.0-M4/modules/implementation-osgi/src/test/resources/osgitest.composite create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/README create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/SCANamespaceHandlerResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaNamespaceHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaPropertyBeanDefinitionParser.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaReferenceBeanDefinitionParser.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/namespace/ScaServiceBeanDefinitionParser.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/InitDestroyAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/resources/META-INF/spring.handlers create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/resources/META-INF/spring.schemas create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring-sca/src/main/resources/org/springframework/sca/xml/spring-sca.xsd create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/README create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/impl-spring-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/implementation-spring/src/main/resources/org/apache/tuscany/sca/implementation/spring/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientImplementationProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/src/main/java/org/apache/tuscany/sca/implementation/web/client/ClientServlet.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-client/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/ComponentContextProxy.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/WebImplementationProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTEI.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/utils/ContextHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/resources/META-INF/sca.tld create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementation.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/WebImplementationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/xml/WebImplementationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.web.WebImplementationFactory create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/test/java/org/apache/tuscany/sca/implementation/web/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/implementation-web/src/test/resources/org/apache/tuscany/sca/implementation/web/xml/TestWeb.composite create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BaseBeanGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/CodeGenerationHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedClassLoader.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/GeneratedDataTypeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSFaultExceptionMapper.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WebServiceInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGenerator.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.FaultExceptionMapper create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean1.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/Bean2.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/BeanInterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/FaultBeanGeneratorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSAsyncInterfaceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JAXWSJavaInterfaceProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/JavaReflectionHelperTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyException.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/MyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/StockQuote.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestAdapter.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestGenericClass.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/TestInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/java/org/apache/tuscany/sca/interfacedef/java/jaxws/WrapperBeanGeneratorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/resources/wsdl/Stock.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-java-jaxws/src/test/resources/wsdl/StockExceptionTest.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/DefaultJavaInterfaceFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceContract.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaOperation.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceContractImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaOperationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/PolicyJavaInterfaceVisitor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/introspect/JavaInterfaceVisitor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/xml/JavaInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/main/resources/interface-javaxml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilDuplicateRemotableTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceUtilTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/JavaInterfaceProcessorRegistryImplTestCase.java.fixme create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/PolicyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/interface-java/src/test/resources/org/apache/tuscany/sca/interfacedef/java/xml/CalculatorImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/BPELPartnerLinkTypeExt.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/DefaultWSDLFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLDefinition.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterface.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLInterfaceContract.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLObject.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/WSDLOperation.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/InvalidWSDLException.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLDefinitionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceContractImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLInterfaceIntrospectorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLObjectImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/impl/WSDLOperationIntrospectorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/BPELExtensionHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLInterfaceProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/main/resources/interface-wsdlxml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLInterfaceIntrospectorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLOperationIntrospectorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WSDLPolicyAnnotatedInterfaceIntrospectorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/introspect/WrapperStyleOperationTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/AbstractWSDLTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/ReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLDocumentProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WSDLTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/java/org/apache/tuscany/sca/interfacedef/wsdl/xml/WriteTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/CalculatorImpl.componentType create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/example.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/invalid-stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/ipo.xsd create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test1.xsd create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/test2.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/org/apache/tuscany/sca/interfacedef/wsdl/xml/unwrapped-stockquote.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/policy/stockquote_policy.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/wsdl/helloworld-interface.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/wsdl/helloworld-service.wsdl create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/xsd/greeting.xsd create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/xsd/helloworld.xsd create mode 100644 branches/sca-java-2.0-M4/modules/interface-wsdl/src/test/resources/xsd/name.xsd create mode 100644 branches/sca-java-2.0-M4/modules/launcher/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/launcher/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/launcher/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/launcher/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/launcher/src/main/java/org/apache/tuscany/sca/launcher/LauncherMain.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/monitor/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/monitor/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/monitor/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/DefaultMonitorFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Monitor.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/MonitorFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/Problem.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/MonitorImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/java/org/apache/tuscany/sca/monitor/impl/ProblemImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/main/resources/META-INF/services/org.apache.tuscany.sca.monitor.MonitorFactory create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/test/java/org/apache/tuscany/sca/monitor/MonitorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/monitor/src/test/resources/org/apache/tuscany/sca/monitor/tuscany-monitor-test-messages_it.properties create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationLifecycleProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/myfaces/src/main/java/org/apache/tuscany/sca/myfaces/TuscanyAnnotationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/node-api/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-api/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/node-api/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Client.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Contribution.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/ContributionLocationHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/Node.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeMain2.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/BindingConfiguration.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/ContributionConfiguration.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DefaultNodeConfigurationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/DeploymentComposite.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfigurationFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/BindingConfigurationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/ContributionConfigurationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/DeploymentCompositeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/NodeManager.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/node/osgi/impl/OSGiNodeFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointDescription.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointListener.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/EndpointPermission.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ExportRegistration.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/ImportRegistration.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteConstants.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdmin.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminEvent.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/RemoteServiceAdminListener.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/EndpointIntrospector.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ExportRegistrationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/ImportRegistrationImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceExporter.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/OSGiServiceImporter.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/RemoteServiceAdminImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/remoteserviceadmin/impl/TopologyManagerImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/AbstractDiscoveryService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/Discovery.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DiscoveryActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/DomainDiscoveryService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/java/org/apache/tuscany/sca/osgi/service/discovery/impl/LocalDiscoveryService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/impl/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/OperationsActivator.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/CalculatorOSGiTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/java/calculator/dosgi/test/OSGiTestBundles.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/blueprint/calculator-module.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/calculator-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/OSGI-INF/remote-service/calculator-service-descriptions.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/bundle.componentType create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/add-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/blueprint/operations-module.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/divide-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/multiply-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/OSGI-INF/subtract-component.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/bundle.componentType create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/operations/operations.composite create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl-osgi/src/test/resources/calculator/dosgi/sca/OSGI-INF/sca/calculator.composite create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationATOMProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/CompositeContextImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManager.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/management/NodeManagerMBean.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.NodeFactory create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.node.configuration.NodeConfigurationFactory create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/main/resources/org/apache/tuscany/sca/node/impl/node-impl-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/java/hello/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/java/hello/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeImplTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/java/org/apache/tuscany/sca/node/impl/NodeUtilTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/resources/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/Contribution.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/ContributionLocationHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/FrameworkLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherException.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher2.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherCommand.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeMain.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/J2SE-1.5.profile create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/JavaSE-1.6.profile create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axiom-api-1.2.7.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/axis2-kernel-1.4.1.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/main/resources/org/apache/tuscany/sca/node/equinox/launcher/woden-impl-dom-1.0M8.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/java/hello/HelloWorld.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/java/hello/HelloWorldClient.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/java/hello/HelloWorldImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHostTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher-equinox/src/test/resources/HelloWorld.composite create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/Contribution.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/LauncherException.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeDaemonLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncher.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeLauncherUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeMain.java create mode 100644 branches/sca-java-2.0-M4/modules/node-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/NodeServletFilter.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/Logging.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingImplementationPolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyBuilder.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/java/org/apache/tuscany/sca/policy/logging/jdk/JDKLoggingServicePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.PolicyBuilder create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/main/resources/org/apache/tuscany/sca/policy/logging/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/test/java/org/apache/tuscany/sca/policy/logging/jdk/PolicyReadTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-logging/src/test/resources/org/apache/tuscany/sca/policy/logging/jdk/mock_policies.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationPrincipal.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationReferencePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/basic/BasicAuthenticationServicePolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authentication/token/TokenPrincipal.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/authorization/AuthorizationPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityImplementationPolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/identity/SecurityIdentityPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/SecurityUtil.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationImplementationPolicyProvider.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicy.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyHandler.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/java/org/apache/tuscany/sca/policy/security/jaas/JaasAuthenticationPolicyProviderFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/org/apache/tuscany/sca/policy/security/tuscany_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/main/resources/policy-security-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/test/java/org/apache/tuscany/sca/policy/security/PolicyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-security/src/test/resources/org/apache/tuscany/sca/policy/security/mock_policy_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/main/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/TestPolicyProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/test/java/org/apache/tuscany/sca/policy/xml/ws/WSPolicyProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/policy-xml-ws/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml create mode 100644 branches/sca-java-2.0-M4/modules/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/ComponentContext.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/Constants.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/InvalidServiceException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchDomainException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/NoSuchServiceException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/RequestContext.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/SCARuntimeException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceRuntimeException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceUnavailableException.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/AllowsPassByReference.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authentication.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Authorization.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Callback.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ComponentName.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Confidentiality.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Constructor.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Context.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Destroy.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EagerInit.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Init.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Integrity.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Intent.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedSharedTransaction.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ManagedTransaction.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/MutualAuthentication.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/NoManagedTransaction.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/OneWay.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/PolicySets.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Property.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Qualifier.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Reference.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Remotable.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Requires.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Scope.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Service.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClient.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/client/SCAClientFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-api/src/main/java/org/oasisopen/sca/client/impl/SCAClientFactoryFinder.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/sca-client-impl/src/main/resources/META-INF/services/org.oasisopen.sca.client.SCAClientFactory create mode 100644 branches/sca-java-2.0-M4/modules/stripes/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/stripes/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/stripes/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/stripes/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyHelper.java create mode 100644 branches/sca-java-2.0-M4/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptor.java create mode 100644 branches/sca-java-2.0-M4/modules/stripes/src/main/java/org/apache/tuscany/sca/stripes/TuscanyInterceptorSupport.java create mode 100644 branches/sca-java-2.0-M4/modules/wicket/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/wicket/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/wicket/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/wicket/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/IContextLocator.java create mode 100644 branches/sca-java-2.0-M4/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyComponentInjector.java create mode 100644 branches/sca-java-2.0-M4/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyFieldValueFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/wicket/src/main/java/org/apache/tuscany/sca/wicket/TuscanyInjector.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/LICENSE create mode 100644 branches/sca-java-2.0-M4/modules/xsd/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/modules/xsd/NOTICE create mode 100644 branches/sca-java-2.0-M4/modules/xsd/pom.xml create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/DefaultXSDFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDFactory.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/XSDefinition.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDFactoryImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/impl/XSDefinitionImpl.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessor.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/java/org/apache/tuscany/sca/xsd/xml/XSDModelResolver.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.xsd.XSDFactory create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/main/resources/xsd-xml-validation-messages.properties create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/test/java/org/apache/tuscany/sca/xsd/xml/XSDDocumentProcessorTestCase.java create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/test/resources/xsd/greeting.xsd create mode 100644 branches/sca-java-2.0-M4/modules/xsd/src/test/resources/xsd/name.xsd create mode 100644 branches/sca-java-2.0-M4/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/README create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/README create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/calculator.svg create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/build-common.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/README create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/calculator.svg create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/README create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/README create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/calculator-rmi-reference.png create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/calculator-rmi-reference.svg create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/README create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/calculator-rmi-service.png create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/calculator-rmi-service.svg create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/README create mode 100644 branches/sca-java-2.0-M4/samples/calculator/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator/calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/calculator/calculator.svg create mode 100644 branches/sca-java-2.0-M4/samples/calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/LICENSE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/NOTICE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/add-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/blueprint/operations-module.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/divide-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/multiply-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.componentType create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/sca/bundle.composite create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/OSGI-INF/subtract-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/README create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/LICENSE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/NOTICE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/OSGI-INF/blueprint/calculator-module.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/OSGI-INF/calculator-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/OSGI-INF/sca/bundle.componentType create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/OSGI-INF/sca/bundle.composite create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/README create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/dosgi-calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/java/calculator/rmi/OperationsRemote.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/LICENSE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/NOTICE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/add-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/blueprint/operations-module.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/divide-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/multiply-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/sca-config/operations-config.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/OSGI-INF/subtract-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/README create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/OperationsActivator.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/main/java/calculator/dosgi/operations/impl/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OSGiTestUtils.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsNode.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator-operations/src/test/java/calculator/dosgi/operations/test/OperationsOSGiNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/LICENSE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/META-INF/MANIFEST.MF create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/NOTICE create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/OSGI-INF/blueprint/calculator-module.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/OSGI-INF/calculator-component.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/OSGI-INF/remote-service/calculator-service-descriptions.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/OSGI-INF/sca-config/calculator-config.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/README create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/dosgi-calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorActivator.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceDSImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/impl/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/dosgi/operations/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRMIServer_Stub.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/main/java/calculator/rmi/OperationsRemote.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorNode.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/CalculatorOSGiNodeTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/dosgi-dynamic-calculator/src/test/java/calculator/dosgi/test/OSGiTestUtils.java create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/README create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/helloworld-bpel.png create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/helloworld-bpel.svg create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/java/helloworld/Hello.java create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/resources/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/resources/helloworld.composite create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/resources/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/main/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/README create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/build.xml create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/calculator.png create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/calculator.svg create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/main/resources/Calculator.composite create mode 100644 branches/sca-java-2.0-M4/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 branches/sca-java-2.0-M4/samples/logging.properties create mode 100644 branches/sca-java-2.0-M4/samples/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/resources/helloworld.bpel create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/resources/helloworld.wsdl create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-bpel/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/README create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldClient.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/java/sample/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/webapp/META-INF/context.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/jetty-env.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jms/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-js-client/src/main/webapp/hello.html create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/README create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientJavaTestService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/java/helloworldrest/ClientTestServiceWebapp.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/java/helloworldrest/HelloWorldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/resources/rest.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/src/main/webapp/style.css create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-rest/target/classes/rest.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/java/sample/HelloworldServlet.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-servlet/src/main/webapp/hello.html create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-stripes/src/main/webapp/index.html create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld/pom.xml create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite create mode 100644 branches/sca-java-2.0-M4/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml (limited to 'branches') diff --git a/branches/sca-java-2.0-M4/BUILDING b/branches/sca-java-2.0-M4/BUILDING new file mode 100644 index 0000000000..9993ef4b96 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/CHANGES b/branches/sca-java-2.0-M4/CHANGES new file mode 100644 index 0000000000..32656d1d1f --- /dev/null +++ b/branches/sca-java-2.0-M4/CHANGES @@ -0,0 +1,69 @@ +Changes With Apache Tuscany SCA 2.0-Mx Xxx 2009 +=============================================== + +Highlights include: +- Support JSONP with + + + + +Changes With Apache Tuscany SCA 2.0-M3 June 2009 +================================================ + +Highlights include: +- Support for and the OASIS BPEL specification +- Support for 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 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 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/branches/sca-java-2.0-M4/LICENSE b/branches/sca-java-2.0-M4/LICENSE new file mode 100644 index 0000000000..ddd30126af --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/NOTICE b/branches/sca-java-2.0-M4/NOTICE new file mode 100644 index 0000000000..0caf950bab --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/README b/branches/sca-java-2.0-M4/README new file mode 100644 index 0000000000..04eb02ea9f --- /dev/null +++ b/branches/sca-java-2.0-M4/README @@ -0,0 +1,19 @@ +Apache Tuscany SCA 2.0-M3 June 2009 README +=========================================== + +Welcome to the Tuscany SCA 2.0-M3 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/branches/sca-java-2.0-M4/RELEASE_NOTES b/branches/sca-java-2.0-M4/RELEASE_NOTES new file mode 100644 index 0000000000..718b4e5c4d --- /dev/null +++ b/branches/sca-java-2.0-M4/RELEASE_NOTES @@ -0,0 +1,73 @@ +Apache Tuscany SCA 2.0-M3 June 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-M3 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. + - 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/branches/sca-java-2.0-M4/archetypes/contribution-jar/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/contribution-jar/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..1e2a0fbb4d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-jar/pom.xml b/branches/sca-java-2.0-M4/archetypes/contribution-jar/pom.xml new file mode 100644 index 0000000000..a172e856a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-jar/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-contribution-jar + maven-archetype + Create an SCA JAR contribution project + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-3 + + + + + maven-archetype-plugin + 2.0-alpha-3 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..46c5cd6dca --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,36 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.xml + **/*.composite + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..69c3fb5ac9 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,30 @@ + + + + tuscany-contribution-jar + + src/main/java/HelloworldImpl.java + src/main/java/HelloworldService.java + + + src/main/hello.composite + src/main/webapp/META-INF/sca-contribution.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..ede059f1e3 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,110 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + jar + ${version} + #literal() + quickstart + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + provided + + + + + junit + junit + 4.5 + test + + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + org.apache.tuscany.maven.plugins + maven-tuscany-plugin + + + + + 2.0-M4-SNAPSHOT + + #end + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java new file mode 100644 index 0000000000..26237c105c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/java/HelloworldService.java new file mode 100644 index 0000000000..d705564334 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..c33da77c0d --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-jar/src/main/resources/archetype-resources/src/main/resources/helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/pom.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/pom.xml new file mode 100644 index 0000000000..bf47329744 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/pom.xml @@ -0,0 +1,33 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-zip-contribution-descriptor + Tuscany SCA ZIP contribution Shared Assembly Descriptor + + + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml new file mode 100644 index 0000000000..a672d2920d --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip-discriptor/src/main/resources/assemblies/tuscany-zip-contribution.xml @@ -0,0 +1,40 @@ + + + + zip-contribution + + zip + + false + + + false + runtime + lib + false + + + + + ${project.build.outputDirectory} + / + + + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/contribution-zip/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b5be2573dd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-zip/pom.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip/pom.xml new file mode 100644 index 0000000000..48b0ea2c9f --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-contribution-zip + maven-archetype + Create an SCA ZIP contribution project + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-3 + + + + + maven-archetype-plugin + 2.0-alpha-3 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..46c5cd6dca --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,36 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/*.xml + **/*.composite + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..c17535e802 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,30 @@ + + + + tuscany-contribution-zip + + src/main/java/AddImpl.java + src/main/java/AddService.java + + + src/main/resources/add.composite + src/main/resources/META-INF/sca-contribution.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..e2667701b0 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,153 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + jar + ${version} + #literal() + quickstart + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + provided + + + + + commons-io + commons-io + 1.4 + + + + commons-math + commons-math + 1.2 + + + + + junit + junit + 4.5 + test + + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + maven-assembly-plugin + 2.2-beta-3 + + + org.apache.tuscany.sca + tuscany-zip-contribution-descriptor + ${tuscany.version} + + + + + make-assembly + package + + single + + + false + + + tuscany-zip-contribution.xml + + + + + + + + org.apache.tuscany.maven.plugins + maven-tuscany-plugin + + + + + 2.0-M4-SNAPSHOT + + #end + diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddImpl.java new file mode 100644 index 0000000000..48b62dbb6f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/java/AddService.java new file mode 100644 index 0000000000..4b25553893 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite new file mode 100644 index 0000000000..2a8b041849 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/contribution-zip/src/main/resources/archetype-resources/src/main/resources/add.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/pom.xml b/branches/sca-java-2.0-M4/archetypes/pom.xml new file mode 100644 index 0000000000..47429e918f --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-archetype + pom + Apache Tuscany SCA Maven Archetypes + + + + default + + true + + + + contribution-jar + contribution-zip + contribution-zip-discriptor + quickstart + quickstart-jsf + quickstart-stripes + quickstart-bpel + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..29e03eb396 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/pom.xml new file mode 100644 index 0000000000..e24c287ed4 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-quickstart-bpel + maven-archetype + Create an SCA Webapp project using BPEL + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-3 + + + + + maven-archetype-plugin + 2.0-alpha-3 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..47c2f5dc10 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,43 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/resources + + **/* + + + + src/main/webapp + + **/*.jsp + **/*.xml + **/*.composite + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..c466a1b3f5 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,33 @@ + + + + tuscany-quickstart + + src/main/java/HelloworldImpl.java + src/main/java/HelloworldService.java + + + src/main/resources/helloworld.bpel + src/main/resources/helloworld.wsdl + src/main/webapp/hello.jsp + src/main/webapp/WEB-INF/web.composite + src/main/webapp/WEB-INF/web.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..ae7de51a2d --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,182 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + war + ${version} + #literal() + quickstart + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + ${tuscany.version} + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-runtime + ${tuscany.version} + runtime + + + + + junit + junit + 4.5 + test + + + + + org.mortbay.jetty + jetty + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-util + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-management + ${jetty.version} + provided + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + compile + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1.1 + zip + false + ${project.build.directory}/classes + **/* + + + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.mortbay.jetty + maven-jetty-plugin + ${jetty.version} + + + + + openjpa.QueryCompilationCache + false + + + + ${basedir}/src/main + ${basedir}/src/main/webapp/WEB-INF/web.xml + + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + + + 2.0-M4-SNAPSHOT + 6.1.18 + + #end + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/java/HelloworldService.java new file mode 100644 index 0000000000..a99cc7b032 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel new file mode 100644 index 0000000000..53e77c5be0 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..46cf381577 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/resources/helloworld.wsdl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..c2aced55f0 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + ${artifactId} + + + tuscany.${artifactId} + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany.${artifactId} + /* + + + + hello.jsp + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart-bpel/src/main/resources/archetype-resources/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..7aeaf81b33 --- /dev/null +++ b/branches/sca-java-2.0-M4/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" %> + + + + + + +

${artifactId}

+ + Calling HelloworldService sayHello("world") returns: + +

+ + <%= service.hello("world") %> + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/pom.xml new file mode 100644 index 0000000000..d1e7fc2eba --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-quickstart-jsf + maven-archetype + Create a Tuscany SCA and JSF project + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-4 + + + + + maven-archetype-plugin + 2.0-alpha-4 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..f15a12fb88 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,44 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/webapp + + **/*.jsp + **/*.xml + **/*.html + **/*.composite + + + + src/main/resources + + **/*.properties + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..b5295d8a73 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,38 @@ + + + + quickstart-stripes + + src/main/java/sample/stripes/action/BaseActionBean.java + src/main/java/sample/stripes/action/HomeActionBean.java + src/main/java/sample/sca/HelloworldService.java + src/main/java/sample/sca/HelloworldServiceImpl.java + + + src/main/resources/log4j.properties + src/main/resources/StripesResources.properties + src/main/webapp/index.html + src/main/webapp/WEB-INF/jsp/home.jsp + src/main/webapp/WEB-INF/jsp/layout.jsp + src/main/webapp/WEB-INF/jsp/taglibs.jsp + src/main/webapp/WEB-INF/web.composite + src/main/webapp/WEB-INF/web.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..04618b4fbf --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,154 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + war + ${version} + #literal() + quickstart-jsf + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + + + org.apache.tuscany.sca + tuscany-myfaces + ${tuscany.version} + + + + + org.apache.myfaces.core + myfaces-api + 1.2.2 + compile + + + + org.apache.myfaces.core + myfaces-impl + 1.2.2 + compile + + + + org.apache.myfaces.tomahawk + tomahawk + 1.1.6 + runtime + + + javax.servlet + jstl + + + + + + jstl + jstl + 1.2 + runtime + + + + junit + junit + 4.0 + test + + + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.mortbay.jetty + maven-jetty-plugin + ${jetty.version} + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + + + 2.0-M4-SNAPSHOT + 1.5 + 6.1.4 + + #end + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/myfaces/HelloWorldController.java new file mode 100644 index 0000000000..e38c84feda --- /dev/null +++ b/branches/sca-java-2.0-M4/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 helloworld.jsp + * + */ +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/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java new file mode 100644 index 0000000000..d6cb7bbcf2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java new file mode 100644 index 0000000000..ec9bfd7221 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/faces-config.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 = '\' ) + + + + + + + helloWorld + ${package}.myfaces.HelloWorldController + request + + + + + /helloWorld.jsp + + success + /page2.jsp + + + + + + /page2.jsp + + back + /helloWorld.jsp + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..eb86cee711 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 = '\' ) + + + + + ${artifactId} + + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + org.apache.myfaces.config.annotation.LifecycleProvider + org.apache.tuscany.sca.myfaces.TuscanyAnnotationLifecycleProvider + + + + + State saving method: "client" or "server" (= default) + See JSF Specification 2.5.3 + javax.faces.STATE_SAVING_METHOD + client + + + Only applicable if state saving method is "server" (= default). + Defines the amount (default = 20) of the latest views are stored in session. + org.apache.myfaces.NUMBER_OF_VIEWS_IN_SESSION + 20 + + + 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. + org.apache.myfaces.SERIALIZE_STATE_IN_SESSION + true + + + 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. + org.apache.myfaces.COMPRESS_STATE_IN_SESSION + true + + + 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" + org.apache.myfaces.ALLOW_JAVASCRIPT + true + + + org.apache.myfaces.DETECT_JAVASCRIPT + false + + + 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" + org.apache.myfaces.PRETTY_HTML + true + + + 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" + org.apache.myfaces.AUTO_SCROLL + true + + + + 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. + + org.apache.myfaces.SECRET + NzY1NDMyMTA= + + + + + Validate managed beans, navigation rules and ensure that forms are not nested. + + org.apache.myfaces.VALIDATE + true + + + + + Treat readonly same as if disabled attribute was set for select elements. + + org.apache.myfaces.READONLY_AS_DISABLED_FOR_SELECTS + true + + + + + 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. + + org.apache.myfaces.ADD_RESOURCE_CLASS + org.apache.myfaces.renderkit.html.util.DefaultAddResource + + + + + Virtual path in the URL which triggers loading of resources for the MyFaces extended components + in the ExtensionFilter. + + org.apache.myfaces.RESOURCE_VIRTUAL_PATH + /faces/myFacesExtensionResource + + + + + Check if the extensions-filter has been properly configured. + + org.apache.myfaces.CHECK_EXTENSIONS_FILTER + true + + + + + Define partial state saving as true/false. + + javax.faces.PARTIAL_STATE_SAVING_METHOD + false + + + + + extensionsFilter + org.apache.myfaces.webapp.filter.ExtensionsFilter + + Set the size limit for uploaded files. + Format: 10 - 10 bytes + 10k - 10 KB + 10m - 10 MB + 1g - 1 GB + uploadMaxFileSize + 100m + + + 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 + uploadThresholdSize + 100k + + + + + extensionsFilter + *.jsf + + + extensionsFilter + /faces/* + + + + + org.apache.myfaces.webapp.StartupServletContextListener + + + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + + + Faces Servlet + *.jsf + + + + + index.jsp + index.html + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp new file mode 100644 index 0000000000..4a3197ec4f --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/helloWorld.jsp @@ -0,0 +1,37 @@ + +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> + + + Hello World + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp new file mode 100644 index 0000000000..768aa2408b --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/index.jsp @@ -0,0 +1,22 @@ + +<%@ page session="false"%> +<% +response.sendRedirect("helloWorld.jsf"); +%> \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp new file mode 100644 index 0000000000..1c096f66c6 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsf/src/main/resources/archetype-resources/src/main/webapp/page2.jsp @@ -0,0 +1,35 @@ + +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> + + + Hello World + + + + +

+ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..29e03eb396 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/pom.xml new file mode 100644 index 0000000000..70538b8fb3 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-quickstart-jsonp + maven-archetype + Create a Tuscany SCA webapp project using the JSONP binding + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-4 + + + + + maven-archetype-plugin + 2.0-alpha-4 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..450e33afd5 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ + + + + + + Y + + + + + src/main/java + + **/*.java + + + + src/main/webapp + + **/*.jsp + **/*.xml + **/*.composite + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..1bf4353502 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,31 @@ + + + + tuscany-quickstart + + src/main/java/HelloworldImpl.java + src/main/java/HelloworldService.java + + + src/main/webapp/hello.jsp + src/main/webapp/WEB-INF/web.composite + src/main/webapp/WEB-INF/web.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..dee32669ee --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,154 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + war + ${version} + quickstart-jsonp + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} +#if(${includeTuscanyRuntime} == "Y") + compile +#else + provided +#end + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + ${tuscany.version} +#if( $includeTuscanyRuntime == "Y") + runtime +#else + provided +#end + + + + org.apache.tuscany.sca + tuscany-binding-jsonp-runtime + ${tuscany.version} +#if( $includeTuscanyRuntime == "Y") + runtime +#else + provided +#end + + + + + junit + junit + 4.5 + test + + + + + org.mortbay.jetty + jetty + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-util + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-management + ${jetty.version} + provided + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.mortbay.jetty + maven-jetty-plugin + ${jetty.version} + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + + + 2.0-M4-SNAPSHOT + 6.1.18 + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java new file mode 100644 index 0000000000..2491816adc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/java/HelloworldService.java new file mode 100644 index 0000000000..3527edcd6f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,43 @@ + + + + + ${artifactId} + +#if($includeTuscanyRuntime == "Y") + + tuscany.${artifactId} + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany.${artifactId} + /* + + +#end + + hello.jsp + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart-jsonp/src/main/resources/archetype-resources/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..9729ca6823 --- /dev/null +++ b/branches/sca-java-2.0-M4/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" %> + + + + + + +

${artifactId}

+ + Calling HelloworldService sayHello("world") returns: + +

+ + <%= service.sayHello("world") %> + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..ae84237c4a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/pom.xml new file mode 100644 index 0000000000..20489472c7 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-quickstart-stripes + maven-archetype + Create a simple Apache Tuscany SCA webapp project using the Stripes Web Framework + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-4 + + + + + maven-archetype-plugin + 2.0-alpha-4 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..f15a12fb88 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,44 @@ + + + + + + src/main/java + + **/*.java + + + + src/main/webapp + + **/*.jsp + **/*.xml + **/*.html + **/*.composite + + + + src/main/resources + + **/*.properties + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..b5295d8a73 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,38 @@ + + + + quickstart-stripes + + src/main/java/sample/stripes/action/BaseActionBean.java + src/main/java/sample/stripes/action/HomeActionBean.java + src/main/java/sample/sca/HelloworldService.java + src/main/java/sample/sca/HelloworldServiceImpl.java + + + src/main/resources/log4j.properties + src/main/resources/StripesResources.properties + src/main/webapp/index.html + src/main/webapp/WEB-INF/jsp/home.jsp + src/main/webapp/WEB-INF/jsp/layout.jsp + src/main/webapp/WEB-INF/jsp/taglibs.jsp + src/main/webapp/WEB-INF/web.composite + src/main/webapp/WEB-INF/web.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..7b2dc15ada --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,124 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + war + ${version} + #literal() + quickstart-stripes + + + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} + + + org.apache.tuscany.sca + tuscany-stripes + ${tuscany.version} + + + + + net.sourceforge.stripes + stripes + ${stripes.version} + + + taglibs + standard + 1.1.2 + + + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.mortbay.jetty + maven-jetty-plugin + ${jetty.version} + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + + + 2.0-M4-SNAPSHOT + 1.5 + 6.1.4 + + #end + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldService.java new file mode 100644 index 0000000000..d6cb7bbcf2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/sca/HelloworldServiceImpl.java new file mode 100644 index 0000000000..390b424d24 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/BaseActionBean.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/java/stripes/action/HomeActionBean.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/StripesResources.properties new file mode 100644 index 0000000000..6567f21ce1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 tag when there are no nested tags +stripes.errors.header=

Please fix the following errors:
    +stripes.errors.beforeError=
  1. +stripes.errors.afterError=
  2. +stripes.errors.footer=
+ +${symbol_pound} Resource strings used by the tag when displaying errors for a +${symbol_pound} specific field (e.g. ). If not supplied the +${symbol_pound} values above will be used instead. +stripes.fieldErrors.header= +stripes.fieldErrors.beforeError= +stripes.fieldErrors.afterError=
+stripes.fieldErrors.footer= + +${symbol_pound} Resource strings used by the stripes:messages tag +stripes.messages.header=
    +stripes.messages.beforeMessage=
  • +stripes.messages.afterMessage=
  • +stripes.messages.footer=
+ +${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={1} 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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/resources/log4j.properties new file mode 100644 index 0000000000..e2fd1997c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/home.jsp b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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" %> + + + +

sayHello returns: ${symbol_dollar}{actionBean.hello}

+

Congratulations, you've set up a Stripes SCA project!

+
+
diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/layout.jsp b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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" %> + + + + + + + ${symbol_dollar}{title} + + + + + +
+ + +
+ + + +
\ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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} --%> + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..4ffadbe621 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 = '\' ) + + + + + ${artifactId} + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + StripesFilter + net.sourceforge.stripes.controller.StripesFilter + + ActionResolver.Packages + ${package}.stripes.action + + + Extension.Packages + org.apache.tuscany.sca.stripes + + + + + DispatcherServlet + net.sourceforge.stripes.controller.DispatcherServlet + 1 + + + + StripesFilter + DispatcherServlet + REQUEST + FORWARD + + + + DispatcherServlet + *.htm + + + + index.html + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html b/branches/sca-java-2.0-M4/archetypes/quickstart-stripes/src/main/resources/archetype-resources/src/main/webapp/index.html new file mode 100644 index 0000000000..a350f1e68a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = '\' ) + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/archetypes/quickstart/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..29e03eb396 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart/pom.xml new file mode 100644 index 0000000000..f198e0d52d --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/pom.xml @@ -0,0 +1,50 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../../pom.xml + + + tuscany-quickstart + maven-archetype + Create a simple Apache Tuscany SCA webapp project + + + + + org.apache.maven.archetype + archetype-packaging + 2.0-alpha-4 + + + + + maven-archetype-plugin + 2.0-alpha-4 + true + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..c132fa0364 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,42 @@ + + + + + + Y + + + + + src/main/java + + **/*.java + + + + src/main/webapp + + **/*.jsp + **/*.xml + **/*.composite + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml new file mode 100644 index 0000000000..7794570626 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/META-INF/maven/archetype.xml @@ -0,0 +1,31 @@ + + + + tuscany-quickstart + + src/main/java/HelloworldImpl.java + src/main/java/HelloworldService.java + + + src/main/webapp/hello.jsp + src/main/webapp/WEB-INF/web.composite + src/main/webapp/WEB-INF/web.xml + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..238b410198 --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,143 @@ + + + + + 4.0.0 + ${groupId} + ${artifactId} + war + ${version} + quickstart + + + + + org.apache.tuscany.sca + tuscany-sca-api + ${tuscany.version} +#if(${includeTuscanyRuntime} == "Y") + compile +#else + provided +#end + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + ${tuscany.version} +#if( $includeTuscanyRuntime == "Y") + runtime +#else + provided +#end + + + + + junit + junit + 4.5 + test + + + + + org.mortbay.jetty + jetty + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-util + ${jetty.version} + provided + + + org.mortbay.jetty + jetty-management + ${jetty.version} + provided + + + + install + ${artifactId} + + + false + src/main/resources + + + false + src/main/java + + ** + + + **/*.java + + + + + + false + src/test/java + + ** + + + **/*.java + + + + + + true + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + true + true + + + + org.mortbay.jetty + maven-jetty-plugin + ${jetty.version} + + + org.apache.maven.plugins + maven-eclipse-plugin + + true + + + + + + 2.0-M4-SNAPSHOT + 6.1.18 + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldImpl.java new file mode 100644 index 0000000000..df80303778 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/java/HelloworldService.java new file mode 100644 index 0000000000..47501efb9a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..9df4cd915e --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..a7c7d2251e --- /dev/null +++ b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,43 @@ + + + + + ${artifactId} + +#if($includeTuscanyRuntime == "Y") + + tuscany.${artifactId} + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany.${artifactId} + /* + + +#end + + hello.jsp + + + diff --git a/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp b/branches/sca-java-2.0-M4/archetypes/quickstart/src/main/resources/archetype-resources/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..9729ca6823 --- /dev/null +++ b/branches/sca-java-2.0-M4/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" %> + + + + + + +

${artifactId}

+ + Calling HelloworldService sayHello("world") returns: + +

+ + <%= service.sayHello("world") %> + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/manifests/axiom-api-1.2.7.MF b/branches/sca-java-2.0-M4/distribution/all/manifests/axiom-api-1.2.7.MF new file mode 100644 index 0000000000..400fdc58e8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/manifests/woden-impl-dom-1.0M8.MF b/branches/sca-java-2.0-M4/distribution/all/manifests/woden-impl-dom-1.0M8.MF new file mode 100644 index 0000000000..b3e9d79d28 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/pom.xml b/branches/sca-java-2.0-M4/distribution/all/pom.xml new file mode 100644 index 0000000000..7aa3d97c9d --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/pom.xml @@ -0,0 +1,120 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-distribution-all + Apache Tuscany SCA All-in-one Distribution + pom + + + + org.apache.tuscany.sca + tuscany-feature-all + pom + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-domain-node + 2.0-M4-SNAPSHOT + + + + + + + org.apache.tuscany.maven.plugins + maven-bundle-plugin + 1.0.4 + + + distribution-modules + generate-resources + + generate-modules + + + target/modules + false + true + + + org.apache.ws.commons.axiom + axiom-api + 1.2.7 + ${basedir}/manifests/axiom-api-1.2.7.MF + + + org.apache.woden + woden-impl-dom + 1.0M8 + ${basedir}/manifests/woden-impl-dom-1.0M8.MF + + + org.apache.axis2 + * + * + + + + + + + + org.eclipse + osgi + 3.3.0-v20070530 + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + distribution-package + package + + single + + + + src/main/assembly/bin.xml + src/main/assembly/src.xml + + gnu + apache-tuscany-sca-all-${version} + true + true + + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/bin.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/bin.xml new file mode 100644 index 0000000000..51033a5e1d --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/bin.xml @@ -0,0 +1,36 @@ + + + + + + true + tuscany-sca-${version} + + tar.gz + zip + + + + src/main/components/bin-common.xml + src/main/components/bin-modules.xml + src/main/components/bin-samples.xml + src/main/components/bin-launcher.xml + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/src.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/src.xml new file mode 100644 index 0000000000..0bb6503560 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/assembly/src.xml @@ -0,0 +1,45 @@ + + + + + src + true + tuscany-sca-${version}-src + + tar.gz + zip + + + + + ../.. + + + **/.* + **/.*/** + **/*.log + **/target + **/target/**/* + **/maven-eclipse.xml + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-common.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-common.xml new file mode 100644 index 0000000000..b5b7111096 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-common.xml @@ -0,0 +1,43 @@ + + + + + + + ../.. + + + CHANGES + README + RELEASE_NOTES + + + + src/main/release/bin + + + INSTALL + LICENSE + NOTICE + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-launcher.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-launcher.xml new file mode 100644 index 0000000000..018e041d38 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-launcher.xml @@ -0,0 +1,41 @@ + + + + + src/main/release/launcher + bin + + + + + + + + bin + false + + org.apache.tuscany.sca:tuscany-launcher + + launcher.jar + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-modules.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-modules.xml new file mode 100644 index 0000000000..89de329d86 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-modules.xml @@ -0,0 +1,33 @@ + + + + + + target + / + + modules/**/* + features/**/* + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-samples.xml b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-samples.xml new file mode 100644 index 0000000000..ebbc5c748f --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/components/bin-samples.xml @@ -0,0 +1,80 @@ + + + + + + ../../samples + samples + + README + logging.properties + build-common.xml + binding-ws-calculator/**/* + calculator/**/* + calculator-equinox/**/* + calculator-osgi/**/* + calculator-rmi-reference/**/* + calculator-rmi-service/**/* + implementation-java-calculator/**/* + dosgi-calculator/**/* + dosgi-calculator-operations/**/* + webapps/helloworld/**/* + webapps/helloworld-bpel/**/* + webapps/helloworld-jsf/**/* + webapps/helloworld-jsp/**/* + webapps/helloworld-stripes/**/* + + + + **/.* + **/.*/** + **/*.log + **/*.svg + **/maven-eclipse.xml + + + pom.xml + + + */target/mvn-eclipse-cache.properties + */target/pom-transformed.xml + */target/classes + */target/classes/**/* + */target/dependency-maven-plugin-markers + */target/dependency-maven-plugin-markers/**/* + */target/.felix + */target/.felix/**/* + */target/maven-archiver + */target/maven-archiver/**/* + */target/test-classes + */target/test-classes/**/* + */target/surefire-reports + */target/surefire-reports/**/* + */target/surefire-osgi-reports + */target/surefire-osgi-reports/**/* + webapps/helloworld/target/**/* + webapps/helloworld-bpel/target/**/* + webapps/helloworld-jsf/target/**/* + webapps/helloworld-jsp/target/**/* + webapps/helloworld-stripes/target/**/* + + + + diff --git a/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/INSTALL b/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/INSTALL new file mode 100644 index 0000000000..7514a7c73c --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/INSTALL @@ -0,0 +1,24 @@ +Installing the Apache Tuscany SCA 2.0-M3 June 2009 Release binary distribution +=============================================================================== + +Unzip Tuscany binary distribution archive and you get the following: + +tuscany-sca-2.0-M3 + 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/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/LICENSE b/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/LICENSE new file mode 100644 index 0000000000..a1c5f8d2e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/LICENSE @@ -0,0 +1,1672 @@ + + 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 + geronimo-activation_1.1_spec-1.0.1.jar + geronimo-connector-2.0.1.jar + geronimo-ejb_2.1_spec-1.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.jar + geronimo-jpa_3.0_spec-1.0.jar + geronimo-jsp_2.1_spec-1.0.1.jar + geronimo-jta_1.1_spec-1.1.jar + geronimo-j2ee-connector_1.5_spec-1.1.1.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 . + + 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 . + + 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 and + Brett McLaughlin . For more information + on the JDOM Project, please see . + +================================================================================ + +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/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/NOTICE b/branches/sca-java-2.0-M4/distribution/all/src/main/release/bin/NOTICE new file mode 100644 index 0000000000..cabd225df1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/README b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/README new file mode 100644 index 0000000000..2d16a081c7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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-M3\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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/default.config b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/default.config new file mode 100644 index 0000000000..d0f68de133 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/osgi.config b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/osgi.config new file mode 100644 index 0000000000..9516b9db34 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.bat b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.bat new file mode 100644 index 0000000000..cbf6962218 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.sh b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/tuscany.sh new file mode 100644 index 0000000000..b053afe4e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/unmanaged.config b/branches/sca-java-2.0-M4/distribution/all/src/main/release/launcher/unmanaged.config new file mode 100644 index 0000000000..ac99590ce9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/pom.xml b/branches/sca-java-2.0-M4/distribution/pom.xml new file mode 100644 index 0000000000..7cbba88043 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/pom.xml @@ -0,0 +1,38 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + ../pom.xml + 2.0-M4-SNAPSHOT + + org.apache.tuscany.sca + tuscany-distribution + pom + Apache Tuscany SCA Distributions + + + all + tomcat + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/README.txt b/branches/sca-java-2.0-M4/distribution/tomcat/README.txt new file mode 100644 index 0000000000..b6158e3667 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/pom.xml new file mode 100644 index 0000000000..efa071389a --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/pom.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + ../pom.xml + 2.0-M4-SNAPSHOT + + org.apache.tuscany.sca + tuscany-distribution-tomcat + pom + Apache Tuscany SCA Distribution Tomcat + + + tomcat-hook + tomcat-servlet + tomcat-war + testing + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/download-tomcat/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/download-tomcat/pom.xml new file mode 100644 index 0000000000..ae49735c48 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/download-tomcat/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution-tomcat-testing + 2.0-M4-SNAPSHOT + ../pom.xml + + + download-tomcat + pom + Apache Tuscany SCA Tomcat Integration Testing Download Tomcat + + + 6.0.18 + + + + + + org.codehaus.mojo + wagon-maven-plugin + 1.0-beta-1 + + + download-tomcat + pre-integration-test + + download-single + + + + http://www.eu.apache.org + dist/tomcat/tomcat-6/v${tomcat.version}/bin/apache-tomcat-${tomcat.version}.zip + download + + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/pom.xml new file mode 100644 index 0000000000..7ea117e7cf --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/pom.xml @@ -0,0 +1,47 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution-tomcat-testing + 2.0-M4-SNAPSHOT + ../pom.xml + + + helloworld-client-webapp + war + Apache Tuscany SCA Tomcat Integration Testing Helloworld Client Webapp + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + provided + + + + + ${artifactId} + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/java/testing/HelloworldService.java new file mode 100644 index 0000000000..8c67e05aa7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..c03a70c58a --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..411d8a3146 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,31 @@ + + + + + jsp-client-webapp + + + hello.jsp + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-client-webapp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..d520375993 --- /dev/null +++ b/branches/sca-java-2.0-M4/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" %> + + + + + + +

jsp-client-webapp

+ + Calling HelloworldService sayHello("world") returns: + +

+ + <%= service.sayHello("world") %> + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/pom.xml new file mode 100644 index 0000000000..ed7378df49 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution-tomcat-testing + 2.0-M4-SNAPSHOT + ../pom.xml + + + helloworld-service-contribution + Apache Tuscany SCA Tomcat Integration Testing Helloworld Service Contribution + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + provided + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldImpl.java new file mode 100644 index 0000000000..c9c6ff66d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/java/testing/HelloworldService.java new file mode 100644 index 0000000000..65e95f275c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..9bdfd4e58b --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..2d6ce9419b --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/helloworld-service-contribution/src/main/resources/helloworld.composite @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/pom.xml new file mode 100644 index 0000000000..64f991464d --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/pom.xml @@ -0,0 +1,36 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + war-legal-checks + Apache Tuscany SCA WAR Distribution Legal Checks + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/branches/sca-java-2.0-M4/distribution/tomcat/testing/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java new file mode 100644 index 0000000000..05f16f603d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 jars = getJarsInDistro(libDirectory); + + List bad2 = getLICENSEJarsNotInDistro(licenseFile, jars); + if (bad2.size() > 0) { + System.err.println("Jars in LICENSE but not in Distribution: " + bad2); + } + + List 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 getLICENSEJarsNotInDistro(File licenseFile, List jars) throws IOException { + List badJars = new ArrayList(); + 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 getJarsNotInLICENSE(List jars, File licenseFile) throws IOException { + List badJars = new ArrayList(); + 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 getJarsInDistro(File directory) { + List jars = new ArrayList(); + 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/branches/sca-java-2.0-M4/distribution/tomcat/testing/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/testing/pom.xml new file mode 100644 index 0000000000..522e452cbc --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/testing/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution-tomcat + ../pom.xml + 2.0-M4-SNAPSHOT + + org.apache.tuscany.sca + tuscany-distribution-tomcat-testing + pom + Apache Tuscany SCA Distribution Tomcat Testing + + + helloworld-service-contribution + helloworld-client-webapp + legal-checks + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/LICENSE b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..70e18a0c9a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/NOTICE b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/NOTICE new file mode 100644 index 0000000000..f5792022fd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/pom.xml new file mode 100644 index 0000000000..a4416d1c1c --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-tomcat-hook + Apache Tuscany SCA Tomcat Hook + + + + + org.apache.tomcat + catalina + 6.0.18 + + + org.apache.tomcat + servlet-api + + + provided + + + + org.apache.tomcat + coyote + 6.0.18 + provided + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.codehaus.swizzle + swizzle-stream + 1.0.2 + provided + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyAnnotationsProcessor.java new file mode 100644 index 0000000000..54947d6492 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyLifecycleListener.java new file mode 100644 index 0000000000..75f925fec5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 + * + */ +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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-hook/src/main/java/org/apache/tuscany/sca/tomcat/TuscanyStandardContext.java new file mode 100644 index 0000000000..5e9b5d90e5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..0b0e3e7d0d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/pom.xml new file mode 100644 index 0000000000..f1cf00d0e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/pom.xml @@ -0,0 +1,63 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-tomcat-servlet + Apache Tuscany SCA Tomcat Integration Servlet + + + + + org.apache.tuscany.sca + tuscany-tomcat-hook + 2.0-M4-SNAPSHOT + provided + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + provided + + + + org.codehaus.swizzle + swizzle-stream + 1.0.2 + + + + javax.servlet + servlet-api + 2.5 + provided + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/tomcat/foo/TuscanyTomcatNode.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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\r\n" + + ""; + + private void updateServerXml(File serverXmlFile) { + String serverXML = readAll(serverXmlFile); + if (!serverXML.contains(tuscanyListener)) { + String newServerXml = replace(serverXML, "", ">" + tuscanyListener); + backup(serverXmlFile); + writeAll(serverXmlFile, newServerXml); + } + + } + + private void removeServerXml(File serverXmlFile) { + String serverXML = readAll(serverXmlFile); + if (serverXML.contains(tuscanyListener)) { + String newServerXml = replace(serverXML, "" + 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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-servlet/src/main/java/org/apache/tuscany/sca/war/InstallerServlet.java new file mode 100644 index 0000000000..a7e5c7e3d7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/pom.xml b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/pom.xml new file mode 100644 index 0000000000..5a26c58401 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/pom.xml @@ -0,0 +1,101 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-war + Apache Tuscany SCA Tomcat Deep Integration WAR + pom + + + + org.codehaus.swizzle + swizzle-stream + 1.0.2 + + + org.apache.tuscany.sca + tuscany-tomcat-servlet + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-tomcat-hook + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-jsonp-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + org.apache.activemq + activemq-core + 5.2.0 + + + + + + tuscany + + + maven-assembly-plugin + + + war + package + + attached + + + + + false + + src/main/assembly/war.xml + + + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/assembly/war.xml b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/assembly/war.xml new file mode 100644 index 0000000000..2f1c6bc4d8 --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/assembly/war.xml @@ -0,0 +1,95 @@ + + + + war + + war + dir + + false + + + ${basedir} + + README.txt + + + + ${basedir}/target/classes + / + + README.txt + NOTICE.txt + LICENSE.txt + + + + ${basedir}/src/main/webapp + / + + + ${basedir}/target/classes + / + + org/** + META-INF/LICENSE + META-INF/NOTICE + + + + ${basedir}/target/classes + WEB-INF/classes + + + ${basedir}/target + lib + + tuscany-host*.jar + + + + + + tuscany-lib + runtime + + org.apache.tomcat:catalina + org.apache.tomcat:annotations-api + org.apache.tomcat:juli + org.apache.tomcat:servlet-api + + + + tomcat-lib + runtime + + org.apache.tuscany.sca:tuscany-tomcat-hook + + + + WEB-INF/lib + runtime + + org.apache.tuscany.sca:tuscany-tomcat-servlet + org.codehaus.swizzle:swizzle-stream + + + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/LICENSE new file mode 100644 index 0000000000..4e1a6a5bf0 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 . + + 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 . + + 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 and + Brett McLaughlin . For more information + on the JDOM Project, please see . + +=============================================================================== + +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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/NOTICE new file mode 100644 index 0000000000..77d1c46d12 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..e6c3d23e9e --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,40 @@ + + + + + + + Tuscany Installer Application + + + InstallerServlet + org.apache.tuscany.sca.war.InstallerServlet + + + + InstallerServlet + /installer + + + + installer.jsp + + + diff --git a/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp new file mode 100644 index 0000000000..a6c3e4acaa --- /dev/null +++ b/branches/sca-java-2.0-M4/distribution/tomcat/tomcat-war/src/main/webapp/installer.jsp @@ -0,0 +1,74 @@ + + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ page import="org.apache.tuscany.sca.war.Installer" %> + +<% + Installer installer = (Installer) request.getAttribute("installer"); +%> + + + + +

Apache Tuscany Tomcat Integration

+ + The Tuscany Tomcat integration turns Tomcat into an SCA enabled runtime so it can run SCA contributions and SCA-enabled Web Applications. +

+ + Status: Tuscany is + <% if (Installer.isTuscanyHookRunning()) { %> + installed and active + <% } else if (Installer.isRestartRequired()) {%> + installed but Tomcat needs to be restarted + <% } else {%> + not installed + <% }%> + + in Tomcat. +

+ + <% if (!Installer.isTuscanyHookRunning() && !Installer.isRestartRequired()) { %> + Install Tuscany
+ To install Tuscany into Tomcat, click: +

+ The Tuscany runtime is shared by all web applications if checked.

+ +

+
+ <% } else {%> + Uninstall Tuscany
+ If remove Tuscany from Tomcat, click: +
+ +
+
+ <% }%> + +

+
+ + + <% if (installer != null) { %> + <%= installer.getStatus() %> + <% }%> + + + + diff --git a/branches/sca-java-2.0-M4/features/all/pom.xml b/branches/sca-java-2.0-M4/features/all/pom.xml new file mode 100644 index 0000000000..b010f4898d --- /dev/null +++ b/branches/sca-java-2.0-M4/features/all/pom.xml @@ -0,0 +1,98 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-all + Apache Tuscany SCA All-in-one Feature + pom + + + + + org.apache.tuscany.sca + tuscany-feature-api + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-webservice + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-web20 + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-ejava + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-webapp + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-process + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-launcher + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-endpoint-tribes + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/features/api/pom.xml b/branches/sca-java-2.0-M4/features/api/pom.xml new file mode 100644 index 0000000000..fbe0a8a144 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/api/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-api + Apache Tuscany SCA API Feature + pom + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-data-api + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/features/core/pom.xml b/branches/sca-java-2.0-M4/features/core/pom.xml new file mode 100644 index 0000000000..1fd1bfb2cb --- /dev/null +++ b/branches/sca-java-2.0-M4/features/core/pom.xml @@ -0,0 +1,230 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-core + Apache Tuscany SCA Core Feature + pom + + + + org.apache.tuscany.sca + tuscany-feature-api + pom + 2.0-M4-SNAPSHOT + + + + + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-assembly-xsd + 2.0-M4-SNAPSHOT + + + + + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-core-databinding + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding-jaxb + 2.0-M4-SNAPSHOT + + + + + + + + org.apache.tuscany.sca + tuscany-extensibility + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 2.0-M4-SNAPSHOT + + + + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-interface-java-jaxws + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-sca-client-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-launcher + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 2.0-M4-SNAPSHOT + + + + + + + org.apache.tuscany.sca + tuscany-monitor + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-policy-security + 2.0-M4-SNAPSHOT + + + + + + org.apache.tuscany.sca + tuscany-xsd + 2.0-M4-SNAPSHOT + + + + diff --git a/branches/sca-java-2.0-M4/features/ejava/pom.xml b/branches/sca-java-2.0-M4/features/ejava/pom.xml new file mode 100644 index 0000000000..d114234f73 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/ejava/pom.xml @@ -0,0 +1,133 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-ejava + Apache Tuscany SCA Enterprise Java Feature + pom + + + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 2.0-M4-SNAPSHOT + + + + + + org.apache.tuscany.sca + tuscany-host-rmi + 2.0-M4-SNAPSHOT + + + + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-spring-sca + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-implementation-osgi-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution-osgi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl-osgi + 2.0-M4-SNAPSHOT + + + + org.eclipse.osgi + services + 3.2.0-v20090520-1800 + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/features/pom.xml b/branches/sca-java-2.0-M4/features/pom.xml new file mode 100644 index 0000000000..97043365e0 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + ../pom.xml + 2.0-M4-SNAPSHOT + + org.apache.tuscany.sca + tuscany-feature + pom + Apache Tuscany SCA Features + + + all + api + core + ejava + process + webservice + web20 + webapp + + + + diff --git a/branches/sca-java-2.0-M4/features/process/pom.xml b/branches/sca-java-2.0-M4/features/process/pom.xml new file mode 100644 index 0000000000..e939c5477f --- /dev/null +++ b/branches/sca-java-2.0-M4/features/process/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-process + Apache Tuscany SCA Process Feature + pom + + + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-implementation-bpel + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-bpel-runtime + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/features/web20/pom.xml b/branches/sca-java-2.0-M4/features/web20/pom.xml new file mode 100644 index 0000000000..4ce517cc31 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/web20/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-web20 + Apache Tuscany SCA Web 2.0 Feature + pom + + + + org.apache.tuscany.sca + tuscany-feature-api + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-binding-atom-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc-runtime + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-databinding-json + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + + + diff --git a/branches/sca-java-2.0-M4/features/webapp/pom.xml b/branches/sca-java-2.0-M4/features/webapp/pom.xml new file mode 100644 index 0000000000..1ca21ef6a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/webapp/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-webapp + Apache Tuscany SCA WebApp Feature + pom + + + + + org.apache.tuscany.sca + tuscany-feature-core + 2.0-M4-SNAPSHOT + pom + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 2.0-M4-SNAPSHOT + + + + + javax.servlet + servlet-api + 2.5 + + + + org.apache.geronimo.specs + geronimo-jsp_2.1_spec + 1.0.1 + + + + org.apache.geronimo.specs + geronimo-el_1.0_spec + 1.0.1 + + + + org.apache.tuscany.sca + tuscany-stripes + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-myfaces + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-binding-jsonp + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-jsonp-runtime + 2.0-M4-SNAPSHOT + + + + + + + diff --git a/branches/sca-java-2.0-M4/features/webservice/pom.xml b/branches/sca-java-2.0-M4/features/webservice/pom.xml new file mode 100644 index 0000000000..73ffeed741 --- /dev/null +++ b/branches/sca-java-2.0-M4/features/webservice/pom.xml @@ -0,0 +1,122 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-feature + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-feature-webservice + Apache Tuscany SCA Web Service Feature + pom + + + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + org.apache.ant + ant-nodeps + + + org.apache.axis2 + addressing + + + org.apache.axis2 + axis2-xmlbeans + + + org.apache.axis2 + axis2-adb-codegen + + + bouncycastle + bcprov-jdk15 + + + opensaml + opensaml + + + + + org.apache.tuscany.sca + tuscany-binding-ws-wsdlgen + 2.0-M4-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-databinding-axiom + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding-jaxb-axiom + 2.0-M4-SNAPSHOT + + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/pom.xml b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/pom.xml new file mode 100644 index 0000000000..624e1dffa7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/pom.xml @@ -0,0 +1,288 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-bpel + 2.0-M4-SNAPSHOT + ../../pom.xml + + itest-bpel-helloworld-reference + Apache Tuscany SCA iTest HelloWorld Reference BPEL + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1 + zip + + + + xerces + xercesImpl + 2.8.0 + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.3.1 + + false + false + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + generate-sources + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1 + zip + true + ${project.build.directory}/test-classes/ + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Djava.endorsed.dirs=target/endorsed + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-sources + + copy + + + + + javax.xml.ws + jaxws-api + 2.1 + jar + + + javax.xml.bind + jaxb-api + 2.1 + jar + + + ${project.build.directory}/endorsed + false + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-test-source + generate-sources + + add-test-source + + + + target/jaxws-source + + + + + + + org.codehaus.mojo + jaxws-maven-plugin + 1.12 + + + + javax.jws + jsr181-api + 1.0-MR1 + + + javax.annotation + jsr250-api + 1.0 + + + + + wsimport + generate-test-sources + + wsimport + + + org.apache.tuscany.implementation.bpel.example.helloworld + ${basedir}/src/test/resources/helloworld/ + + helloworld.wsdl + + ${project.build.directory}/jaxws-source + false + true + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsService.java new file mode 100644 index 0000000000..d7dff093f9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsServiceImpl.java new file mode 100644 index 0000000000..5ecf5494be --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/greetings/GreetingsTestCase.java new file mode 100644 index 0000000000..24ab0a4181 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..f46893481b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..a687534bb2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..a9268ac1b5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite new file mode 100644 index 0000000000..faa10b90ca --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl new file mode 100644 index 0000000000..b976a53970 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/greetings/greetings.wsdl @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel new file mode 100644 index 0000000000..c0317687df --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.bpel @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + $helloMessage.TestPart + $greetingsRequest.request + + + + + + + + $greetingsResponse.parameters/greetings:GreetingsResponse + $helloMessageResponse.TestPart + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..590f05ee84 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl new file mode 100644 index 0000000000..541a713112 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/helloworld/helloworld.wsdl @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/log4j.properties b/branches/sca-java-2.0-M4/itest/bpel/helloworld-reference/src/test/resources/log4j.properties new file mode 100644 index 0000000000..4e13380e0b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/pom.xml b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/pom.xml new file mode 100644 index 0000000000..0e4f8dbef8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/pom.xml @@ -0,0 +1,178 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-bpel + 2.0-M4-SNAPSHOT + ../../pom.xml + + itest-bpel-helloworld-ws + + Apache Tuscany SCA iTest HelloWorld BPEL Over Web Services + + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + runtime + + + + xerces + xercesImpl + 2.8.1 + + + + org.apache.tuscany.sca + tuscany-host-jetty + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.3.1 + + false + false + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + + unpack + test-compile + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + + 1.1 + zip + true + ${project.build.directory}/test-classes/ + + + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.1.1 + + + generate-bpel-helloworld + generate-sources + + + ${basedir}/src/test/resources/helloworld/helloworld.wsdl + + ${basedir}/target/wsdl2java-source + + HelloWorld + true + true + true + + + generate + + + + + + org.apache.tuscany.sca + tuscany-maven-wsdl2java + + 1.6-SNAPSHOT + + + + + + + ${basedir}/src/test/resources/helloworld/helloworld.wsdl + + + + + + generate + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..0999e97065 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..315591fb98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel new file mode 100644 index 0000000000..8cf91adc2c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..f42325910d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl new file mode 100644 index 0000000000..610bda3cc4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/helloworld/helloworld.wsdl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/log4j.properties b/branches/sca-java-2.0-M4/itest/bpel/helloworld-ws/src/test/resources/log4j.properties new file mode 100644 index 0000000000..37f66e4189 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld/pom.xml b/branches/sca-java-2.0-M4/itest/bpel/helloworld/pom.xml new file mode 100644 index 0000000000..fc0f67fcf5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld/pom.xml @@ -0,0 +1,270 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-bpel + 2.0-M4-SNAPSHOT + ../../pom.xml + + itest-bpel-helloworld + Apache Tuscany SCA iTest HelloWorld BPEL + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-runtime + 2.0-M4-SNAPSHOT + runtime + + + + xerces + xercesImpl + 2.8.1 + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-surefire-plugin + + 2.3.1 + + false + false + true + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + test-compile + + unpack + + + + + org.apache.ode + ode-dao-jpa-ojpa-derby + 1.1 + zip + true + ${project.build.directory}/test-classes/ + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Djava.endorsed.dirs=target/endorsed + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + generate-sources + + copy + + + + + javax.xml.ws + jaxws-api + 2.1 + jar + + + javax.xml.bind + jaxb-api + 2.1 + jar + + + ${project.build.directory}/endorsed + false + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-test-source + generate-sources + + add-test-source + + + + target/jaxws-source + + + + + + + org.codehaus.mojo + jaxws-maven-plugin + 1.12 + + + + javax.jws + jsr181-api + 1.0-MR1 + + + javax.annotation + jsr250-api + 1.0 + + + + + wsimport + generate-test-sources + + wsimport + + + org.apache.tuscany.implementation.bpel.example.helloworld + ${basedir}/src/test/resources/helloworld/ + + helloworld.wsdl + + ${project.build.directory}/jaxws-source + false + true + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..0999e97065 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..86e6e4e9c5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel new file mode 100644 index 0000000000..156e32e9ee --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.bpel @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + concat($helloMessage.TestPart/test:message/text(), ' World') + + + + + + + + Dummy + + + + + + + + $helloMessageResponse.TestResponse/test:messageResponse + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..832c8f3702 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl new file mode 100644 index 0000000000..c77318e8fd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/helloworld/helloworld.wsdl @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/log4j.properties b/branches/sca-java-2.0-M4/itest/bpel/helloworld/src/test/resources/log4j.properties new file mode 100644 index 0000000000..37f66e4189 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/bpel/pom.xml b/branches/sca-java-2.0-M4/itest/bpel/pom.xml new file mode 100644 index 0000000000..fe4f206ca4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/bpel/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-bpel + pom + Apache Tuscany SCA BPEL Integration Tests + + + helloworld + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/pom.xml b/branches/sca-java-2.0-M4/itest/builder/pom.xml new file mode 100644 index 0000000000..ea51a8e879 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-builder + Apache Tuscany SCA iTest Builder + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-monitor + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-sca-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-core-databinding + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + xerces + xercesImpl + 2.8.1 + test + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDImpl.java new file mode 100644 index 0000000000..b0dc7a6389 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentDReferenceMultiplicityImpl.java new file mode 100644 index 0000000000..bf73a64027 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 reference3a; + + public String getGreetings(String name) { + return "Hello, " + name + "!"; + } + + public String getGreetings2(String name) { + return "Goodbye, " + name + "!"; + } + +} diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentEImpl.java new file mode 100644 index 0000000000..6f36b1c55a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/ComponentFImpl.java new file mode 100644 index 0000000000..8c5c5de208 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3.java new file mode 100644 index 0000000000..f4b8d2cf39 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java b/branches/sca-java-2.0-M4/itest/builder/src/main/java/org/apache/tuscany/sca/itest/builder/Service3a.java new file mode 100644 index 0000000000..299f7606e3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d8cb23bbd3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1.composite new file mode 100644 index 0000000000..4e58cdfa16 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1a.composite new file mode 100644 index 0000000000..06b273c7a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario1/scenario1a.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..ac01b3c687 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10.composite new file mode 100644 index 0000000000..2d127a7bec --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10.composite @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10a.composite new file mode 100644 index 0000000000..98103e360e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/scenario10a.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/service3.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/service3.wsdl new file mode 100644 index 0000000000..2477e23dc6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario10/service3.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8b82b43c68 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11.composite new file mode 100644 index 0000000000..2f5ca96d07 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11.composite @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11a.composite new file mode 100644 index 0000000000..381ccddcc3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/scenario11a.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/service3.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/service3.wsdl new file mode 100644 index 0000000000..2477e23dc6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario11/service3.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..4028098023 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12.composite new file mode 100644 index 0000000000..23799f8487 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12a.composite new file mode 100644 index 0000000000..a2b4f88dc3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario12/scenario12a.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..1da59d5f04 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13.composite new file mode 100644 index 0000000000..631e38855f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13a.composite new file mode 100644 index 0000000000..98976dc4e8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario13/scenario13a.composite @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b1d01afafb --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2.composite new file mode 100644 index 0000000000..7672595959 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2a.composite new file mode 100644 index 0000000000..2fe3592d12 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario2/scenario2a.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..22950dfe03 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3.composite new file mode 100644 index 0000000000..84f42c60fc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3a.composite new file mode 100644 index 0000000000..18ed91142c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario3/scenario3a.composite @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..a17e27c9d8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4.composite new file mode 100644 index 0000000000..a0bdb0197d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4a.composite new file mode 100644 index 0000000000..1b4cf27c76 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario4/scenario4a.composite @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..83a232db6e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5.composite new file mode 100644 index 0000000000..2326afd2f2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5a.composite new file mode 100644 index 0000000000..fdf1423b66 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenario5a.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenarios.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenarios.wsdl new file mode 100644 index 0000000000..5cda7327dd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario5/scenarios.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..776dfe4d97 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6.composite new file mode 100644 index 0000000000..9575612d51 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6a.composite new file mode 100644 index 0000000000..9c7b58e2cb --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenario6a.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenarios.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenarios.wsdl new file mode 100644 index 0000000000..5cda7327dd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario6/scenarios.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..ede31d6bee --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7.composite new file mode 100644 index 0000000000..e1d2e0cefe --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7a.composite new file mode 100644 index 0000000000..ef16dc0785 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenario7a.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenarios.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenarios.wsdl new file mode 100644 index 0000000000..5cda7327dd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario7/scenarios.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..7bb9e694a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8.composite new file mode 100644 index 0000000000..467b7f57fa --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8a.composite new file mode 100644 index 0000000000..9d9b5ba945 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenario8a.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenarios.wsdl b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenarios.wsdl new file mode 100644 index 0000000000..5cda7327dd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario8/scenarios.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b6ec160506 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9.composite new file mode 100644 index 0000000000..83584ed482 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9a.composite b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9a.composite new file mode 100644 index 0000000000..0021ec242b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/builder/src/main/resources/scenario9/scenario9a.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java b/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/BuilderTestCase.java new file mode 100644 index 0000000000..6d41581371 --- /dev/null +++ b/branches/sca-java-2.0-M4/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: 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 and uri="/Service1" + // No other services on ComponentD should have + 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 + for (ComponentService service : componentD.getServices()) { + assert !"$promoted$Service1".equals(service.getName()); + assert service.getBinding(WebServiceBinding.class) == null; + } + } + + // No services on ComponentB should have + Component componentB = TestUtils.getComponent(domainComposite, "ComponentB"); + for (ComponentService service : componentB.getServices()) { + assert service.getBinding(WebServiceBinding.class) == null; + } + + // No services on CompositeC should have + 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: 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 + 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: 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: 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 to inner composite service CompositeC/Service2 + // No other services on CompositeC should have + 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 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 + 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 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 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 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 , 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: and 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 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 to inner component reference ComponentD/reference3 with uri="http://foo.com/bar" + // Should set 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 to any inner component references + for (ComponentReference reference : componentD.getReferences()) { + assert reference.getBinding(WebServiceBinding.class) == null; + } + } + + // Should not add or 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: and 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 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 to inner component reference ComponentD/reference3 with uri="http://foo.com/bar" + // Should set 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 to any inner component references + for (ComponentReference reference : componentD.getReferences()) { + assert reference.getBinding(WebServiceBinding.class) == null; + } + } + + // No references on CompositeC should have or , 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 and 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: and 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: and 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 + // 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 and 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 and 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 and 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/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java new file mode 100644 index 0000000000..27768f3799 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java b/branches/sca-java-2.0-M4/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/TestUtils.java new file mode 100644 index 0000000000..c5eb7a70ea --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-api/pom.xml b/branches/sca-java-2.0-M4/itest/callback-api/pom.xml new file mode 100644 index 0000000000..489c39089c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-api/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-api + Apache Tuscany SCA iTest Callback API + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + + + ${basedir}/../build-was-integration.xml + ${basedir}/../wasAdmin.py + + diff --git a/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java b/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiCallBack.java new file mode 100644 index 0000000000..b013462f9f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java b/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClient.java new file mode 100644 index 0000000000..252e4dc45f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java b/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiClientImpl.java new file mode 100644 index 0000000000..d883dc2d6f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java b/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiService.java new file mode 100644 index 0000000000..afb7c45e2c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java b/branches/sca-java-2.0-M4/itest/callback-api/src/main/java/org/apache/tuscany/sca/test/CallBackApiServiceImpl.java new file mode 100644 index 0000000000..44f57b4316 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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.
+ * 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.
+ * 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/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/CallBackApiTest.composite b/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/CallBackApiTest.composite new file mode 100644 index 0000000000..309311e258 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/CallBackApiTest.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..55736e5254 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-api/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java b/branches/sca-java-2.0-M4/itest/callback-api/src/test/java/org/apache/tuscany/sca/test/CallBackApiTestCase.java new file mode 100644 index 0000000000..75fab95efb --- /dev/null +++ b/branches/sca-java-2.0-M4/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
+ * This function calls the run function defined in the CallBackApiClinet Interface
+ * which in turn executes the following test cases.
+ * 1. Basic callback patterns
+ * 2. Test in which the target does not call back to the client
+ * 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/branches/sca-java-2.0-M4/itest/callback-basic-ws/pom.xml b/branches/sca-java-2.0-M4/itest/callback-basic-ws/pom.xml new file mode 100644 index 0000000000..6f00bcb668 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic-ws/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-basic-ws + Apache Tuscany SCA iTest Callback Basic WebServices + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + + ${basedir}/../build-was-integration.xml + ${basedir}/../wasAdmin.py + + diff --git a/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java new file mode 100644 index 0000000000..291a72b9d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java new file mode 100644 index 0000000000..19f366c423 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java new file mode 100644 index 0000000000..4bb6b29a8d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java new file mode 100644 index 0000000000..5396879e83 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java new file mode 100644 index 0000000000..07010f61e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite new file mode 100644 index 0000000000..db1a2fbf6a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/CallBackBasicTest.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b58fabcd79 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/branches/sca-java-2.0-M4/itest/callback-basic-ws/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java new file mode 100644 index 0000000000..43b812faed --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/pom.xml b/branches/sca-java-2.0-M4/itest/callback-basic/pom.xml new file mode 100644 index 0000000000..1a743c224a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-basic + Apache Tuscany SCA iTest Callback Basic + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + + + ${basedir}/../build-was-integration.xml + ${basedir}/../wasAdmin.py + + diff --git a/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicCallBack.java new file mode 100644 index 0000000000..291a72b9d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClient.java new file mode 100644 index 0000000000..19f366c423 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicClientImpl.java new file mode 100644 index 0000000000..4bb6b29a8d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicService.java new file mode 100644 index 0000000000..5396879e83 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/java/org/apache/tuscany/sca/test/CallBackBasicServiceImpl.java new file mode 100644 index 0000000000..07010f61e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/CallBackBasicTest.composite b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/CallBackBasicTest.composite new file mode 100644 index 0000000000..87cde940e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/CallBackBasicTest.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b58fabcd79 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-basic/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java b/branches/sca-java-2.0-M4/itest/callback-basic/src/test/java/org/apache/tuscany/sca/test/CallBackBasicTestCase.java new file mode 100644 index 0000000000..43b812faed --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/pom.xml b/branches/sca-java-2.0-M4/itest/callback-complex-type/pom.xml new file mode 100644 index 0000000000..3a4b60f7e0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-complex-type/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-complex-type + Apache Tuscany SCA iTest Callback Complex Type + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeCallBack.java new file mode 100644 index 0000000000..627d37e27d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClient.java new file mode 100644 index 0000000000..966ad17b9a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeClientImpl.java new file mode 100644 index 0000000000..d2dc0add75 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeService.java new file mode 100644 index 0000000000..32ab1bdd3e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/java/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.java new file mode 100644 index 0000000000..f7a1a195ed --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite new file mode 100644 index 0000000000..2eea567fff --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/CallBackCTypeClient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType new file mode 100644 index 0000000000..af0b373472 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/main/resources/org/apache/tuscany/sca/test/CallBackCTypeServiceImpl.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java b/branches/sca-java-2.0-M4/itest/callback-complex-type/src/test/java/org/apache/tuscany/sca/test/CallBackCTypeTestCase.java new file mode 100644 index 0000000000..dde489d766 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/pom.xml b/branches/sca-java-2.0-M4/itest/callback-multiple-wires/pom.xml new file mode 100644 index 0000000000..b70e05f622 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-multiple-wires/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-multiple-wires + Apache Tuscany SCA iTest Callback With Mutiple Wires + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl1.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyClientImpl2.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceCallback.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/java/org/apache/tuscany/sca/test/callback/MyServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite b/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite new file mode 100644 index 0000000000..3d0b37eeae --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/main/resources/CallbackMultiWireTest.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-multiple-wires/src/test/java/org/apache/tuscany/sca/test/callback/CallbackMultiWireTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-separatethread/pom.xml b/branches/sca-java-2.0-M4/itest/callback-separatethread/pom.xml new file mode 100644 index 0000000000..e88cecf530 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-separatethread/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-callback-separatethread + Apache Tuscany SCA iTest Callback Using Separate Thread + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClient.java new file mode 100644 index 0000000000..dc66003604 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadClientImpl.java new file mode 100644 index 0000000000..f03144db8a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorCallBack.java new file mode 100644 index 0000000000..137ea6a658 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorService.java new file mode 100644 index 0000000000..4bf05fc925 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/java/org/apache/tuscany/sca/itest/EventProcessorServiceImpl.java new file mode 100644 index 0000000000..bec98a49c9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 clientCallback; + + /** + * This map contains the call backs for each of the registered Event names + */ + private final Map> eventListeners; + + /** + * The list of all Event Generators we create + */ + private final EventGenerator[] allEventGenerators; + + /** + * Constructor. Starts the Event Generators + */ + public EventProcessorServiceImpl() { + eventListeners = new ConcurrentHashMap>(); + + // 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 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/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite new file mode 100644 index 0000000000..f803fb2ec9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/main/resources/CallBackSeparateThreadTest.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java b/branches/sca-java-2.0-M4/itest/callback-separatethread/src/test/java/org/apache/tuscany/sca/itest/CallBackSeparateThreadTestCase.java new file mode 100644 index 0000000000..c216cab1be --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/pom.xml b/branches/sca-java-2.0-M4/itest/component-type/pom.xml new file mode 100644 index 0000000000..ea829d874b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-component-type + Apache Tuscany SCA iTest Component Type + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddService.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddServiceImpl.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..8b6fe066a6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorClient.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..6f978bd9be --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorService.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..1209ac128a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideService.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideServiceImpl.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyService.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractService.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java b/branches/sca-java-2.0-M4/itest/component-type/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..77b128ab8d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/Calculator.composite b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..ecee33e072 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType new file mode 100644 index 0000000000..78e169deb4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/AddServiceImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType new file mode 100644 index 0000000000..5d66becedf --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/CalculatorServiceImpl.componentType @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType new file mode 100644 index 0000000000..22236ae0d0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/DivideServiceImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType new file mode 100644 index 0000000000..2035d617e5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/MultiplyServiceImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType new file mode 100644 index 0000000000..fe76f553be --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/component-type/src/main/resources/calculator/SubtractServiceImpl.componentType @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/component-type/src/test/java/calculator/CalculatorTestCase.java b/branches/sca-java-2.0-M4/itest/component-type/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..ac3ccc3d08 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-folder/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-folder/pom.xml new file mode 100644 index 0000000000..05cabb9b90 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-folder/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-contribution-folder + Apache Tuscany SCA iTest Contribution Folder + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/calculator/CalculatorService.java b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..b4c677b371 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/java/test/ContributionFolderTestCase.java new file mode 100644 index 0000000000..ef2a43c766 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite new file mode 100644 index 0000000000..f67b212d99 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..27a1ee74e4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar new file mode 100644 index 0000000000..fe264693fe Binary files /dev/null and b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/service.jar differ diff --git a/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar new file mode 100644 index 0000000000..d5dfb647d3 Binary files /dev/null and b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository/folderWithJars/serviceImpl.jar differ diff --git a/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository3/contribution.zip b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository3/contribution.zip new file mode 100644 index 0000000000..b293aa4bcc Binary files /dev/null and b/branches/sca-java-2.0-M4/itest/contribution-folder/src/test/resources/repository3/contribution.zip differ diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/pom.xml new file mode 100644 index 0000000000..1ab420e93c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-export-composite + Apache Tuscany SCA iTest Contribution Export + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/Hello.java new file mode 100644 index 0000000000..669821261c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/java/hello/HelloImpl.java new file mode 100644 index 0000000000..ff9f6e75f3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..bea6f39932 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/hello.composite b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/hello.composite new file mode 100644 index 0000000000..aeeab337fa --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/main/resources/hello.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-composite/src/test/java/org/apache/tuscany/sca/test/contribution/HelloTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/pom.xml new file mode 100644 index 0000000000..cca05b9bb9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-export-java + Apache Tuscany SCA iTest Contribution Java Export + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..268d90e910 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..7e11adcec7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType new file mode 100644 index 0000000000..5a14b41650 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-java/src/main/resources/helloworld/HelloWorldImpl.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/pom.xml new file mode 100644 index 0000000000..d8133c4acc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-export-resource + Apache Tuscany SCA iTest Contribution Resource Export + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..f11eacb416 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html new file mode 100644 index 0000000000..1ff281373a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-resource/src/main/resources/ufservices/store.html @@ -0,0 +1,27 @@ + + + +Store + + + +

Sample Store Page

+ + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/pom.xml new file mode 100644 index 0000000000..7c504aee50 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-export-wsdl + Apache Tuscany SCA iTest Contribution WSDL Export + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8254b667f2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..0172fb2c7c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd new file mode 100644 index 0000000000..d49e2ead99 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/export-wsdl/src/main/resources/helloworld.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/pom.xml new file mode 100644 index 0000000000..40dab26baa --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-import-composite + Apache Tuscany SCA iTest Contribution Import + + + + org.apache.tuscany.sca + itest-contribution-export-composite + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c062afaed0 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..e03ed4dc25 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..268d90e910 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..130aa91093 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,27 @@ + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..0172fb2c7c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd new file mode 100644 index 0000000000..d49e2ead99 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworld.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..44ceba1240 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/main/resources/helloworldws.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-composite/src/test/java/org/apache/tuscany/test/contribution/HelloWorldServerTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/pom.xml new file mode 100644 index 0000000000..91eb35d6c1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-import-java + Apache Tuscany SCA iTest Contribution Java Import + + + + org.apache.tuscany.sca + itest-contribution-export-java + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..224e2c4d79 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..a53117e72f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/main/resources/helloworldws.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-java/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/pom.xml new file mode 100644 index 0000000000..0696df1951 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/pom.xml @@ -0,0 +1,102 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-import-resource + Apache Tuscany SCA iTest Contribution Resource Import + + + + + org.apache.tuscany.sca + itest-contribution-export-resource + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-http + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.6-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-contribution-resource + 1.6-SNAPSHOT + test + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..ac6d7becb3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/store.composite b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/store.composite new file mode 100644 index 0000000000..bb5a7b764f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/main/resources/store.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-resource/src/test/java/org/apache/tuscany/sca/test/contribution/StoreTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/pom.xml new file mode 100644 index 0000000000..3d8b5e85c3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-import-wsdl + Apache Tuscany SCA iTest Contribution WSDL Import + + + + org.apache.tuscany.sca + itest-contribution-export-wsdl + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 1.6-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.6-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..e03ed4dc25 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..268d90e910 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..a47b9a71e9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..76ccf71fb8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/main/resources/helloworldws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-import-export/import-wsdl/src/test/java/org/apache/tuscany/sca/test/contribution/HelloWorldServerTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-import-export/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-import-export/pom.xml new file mode 100644 index 0000000000..e64ff002e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-import-export/pom.xml @@ -0,0 +1,56 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 1.6-SNAPSHOT + ../pom.xml + + itest-contribution-import-export + pom + Apache Tuscany SCA Contribution Import/Export Integration Tests + + + export-composite + export-java + export-resource + export-wsdl + import-composite + import-java + import-resource + import-wsdl + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 1.6-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution-impl + 1.6-SNAPSHOT + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-zip/pom.xml b/branches/sca-java-2.0-M4/itest/contribution-zip/pom.xml new file mode 100644 index 0000000000..c637d685ac --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/contribution-zip/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-contribution-zip + Apache Tuscany SCA iTest Contribution ZIP + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + diff --git a/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/calculator/CalculatorService.java b/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..b4c677b371 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java b/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/java/org/apache/tuscany/sca/contribution/zip/ContributionZIPTestCase.java new file mode 100644 index 0000000000..303e2a6d9a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/resources/repository/contribution.zip b/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/resources/repository/contribution.zip new file mode 100644 index 0000000000..3239ae1242 Binary files /dev/null and b/branches/sca-java-2.0-M4/itest/contribution-zip/src/test/resources/repository/contribution.zip differ diff --git a/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/build.xml b/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/build.xml new file mode 100644 index 0000000000..68e15d4a8b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/build.xml @@ -0,0 +1,24 @@ + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/pom.xml new file mode 100644 index 0000000000..3f22b55dea --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/bin-distro-unzip/pom.xml @@ -0,0 +1,138 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-bin-distro-unzip + Apache Tuscany SCA iTest Bin Distro Unzip + + + + org.apache.tuscany.sca + tuscany-distribution-all + pom + 2.0-M4-SNAPSHOT + + + + + + + + not-sun-jdk + + + ${java.home}/../lib/tools.jar + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + + + run-samples + verify + + run + + + + + + + + + + + + + + + + + sun-jdk + + + ${java.home}/../lib/tools.jar + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + sun.jdk + tools + 1.6 + system + ${java.home}/../lib/tools.jar + + + + + + run-samples + verify + + run + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/build.xml b/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/build.xml new file mode 100644 index 0000000000..ed22bce2dc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/build.xml @@ -0,0 +1,40 @@ + + + + ${java.home} + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/pom.xml new file mode 100644 index 0000000000..71e83d01af --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/binding-ws-calculator/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-binding-ws-calculator + Apache Tuscany SCA iTest Distribution binding-ws-calculator + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + sun.jdk + tools + 1.6 + system + ${java.home}/../lib/tools.jar + + + + + + run-samples + verify + + run + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/build.xml b/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/build.xml new file mode 100644 index 0000000000..25abf4e040 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/pom.xml new file mode 100644 index 0000000000..f923ecfb15 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/calculator-rmi/pom.xml @@ -0,0 +1,81 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-calculator-rmi + Apache Tuscany SCA iTest Distribution calculator-rmi + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + sun.jdk + tools + 1.6 + system + ${java.home}/../lib/tools.jar + + + + + + run-samples + verify + + run + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/build.xml b/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/build.xml new file mode 100644 index 0000000000..106fee758c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/build.xml @@ -0,0 +1,40 @@ + + + + ${java.home} + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/pom.xml new file mode 100644 index 0000000000..5d5688af02 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/implementation-java-calculator/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-implementation-java-calculator + Apache Tuscany SCA iTest Distribution implementation-java-calculator + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + sun.jdk + tools + 1.6 + system + ${java.home}/../lib/tools.jar + + + + + + run-samples + verify + + run + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/legal-checks/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/legal-checks/pom.xml new file mode 100644 index 0000000000..79d3974cee --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/legal-checks/pom.xml @@ -0,0 +1,42 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-legal-checks + Apache Tuscany SCA iTest Distribution Legal Checks + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java b/branches/sca-java-2.0-M4/itest/distribution/legal-checks/src/test/java/itest/JarsInLICENSETestCase.java new file mode 100644 index 0000000000..2cbbe57125 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 jars = getJarsInDistro(libDirectory); + + List bad2 = getLICENSEJarsNotInDistro(licenseFile, jars); + if (bad2.size() > 0) { + System.err.println("Jars in LICENSE but not in Distribution: " + bad2); + } + + List 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 getLICENSEJarsNotInDistro(File licenseFile, List jars) throws IOException { + List badJars = new ArrayList(); + 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 getJarsNotInLICENSE(List jars, File licenseFile) throws IOException { + List badJars = new ArrayList(); + 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 getJarsInDistro(File directory) { + List jars = new ArrayList(); + 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/branches/sca-java-2.0-M4/itest/distribution/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/pom.xml new file mode 100644 index 0000000000..0dd9527c47 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + pom + itest-distribution + Apache Tuscany SCA iTest Distribution + + + install + + + + bin-distro-unzip + binding-ws-calculator + calculator-rmi + implementation-java-calculator + legal-checks + webapp-helloworld + webapp-helloworld-bpel + webapp-helloworld-js-client + webapp-helloworld-jsp + webapp-helloworld-stripes + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/pom.xml new file mode 100644 index 0000000000..c748cf771b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/pom.xml @@ -0,0 +1,124 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-bpel + Apache Tuscany SCA iTest Distribution Webapp helloworld-bpel + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-bpel + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + jetty6x + embedded + + org.apache.commons.logging.impl.SimpleLog + + + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-bpel + + + + org.apache.tuscany.sca + helloworld-bpel + war + + helloworld-bpel + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-bpel/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..5b29292acf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/pom.xml new file mode 100644 index 0000000000..f209a4fcd8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/pom.xml @@ -0,0 +1,216 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-jms + Apache Tuscany SCA iTest Distribution Webapp helloworld-jms + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-jms + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + org.mortbay.jetty + jsp-2.0 + 6.1.19 + pom + compile + + + org.mortbay.jetty + jetty-naming + 6.1.19 + + + org.mortbay.jetty + jetty-plus + 6.1.19 + + + geronimo-spec + geronimo-spec-jta + 1.0.1B-rc4 + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + + jetty6x + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer + + embedded + + + + org.mortbay.jetty + jetty + + + org.mortbay.jetty + jetty-util + + + org.mortbay.jetty + jetty-plus + + + org.mortbay.jetty + jetty-naming + + + geronimo-spec + geronimo-spec-jta + + + javax.servlet + servlet-api + + + org.mortbay.jetty + jsp-2.0 + + + tomcat + jasper-runtime + + + tomcat + jasper-compiler + + + commons-logging + commons-logging + + + tomcat + jasper-compiler-jdt + + + org.mortbay.jetty + jsp-api-2.0 + + + commons-el + commons-el + + + + + + + + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-jms + + + + org.apache.tuscany.sca + helloworld-jms + war + + helloworld-jms + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jms/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..bc436667c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/pom.xml new file mode 100644 index 0000000000..8649b9354c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/pom.xml @@ -0,0 +1,188 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-js-client + Apache Tuscany SCA iTest Distribution Webapp helloworld-js-client + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-js-client + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + org.mortbay.jetty + jsp-2.0 + 6.1.19 + pom + compile + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + + latest-jetty6x + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer + + embedded + + + + org.mortbay.jetty + jetty + + + org.mortbay.jetty + jetty-util + + + javax.servlet + servlet-api + + + org.mortbay.jetty + jsp-2.0 + + + tomcat + jasper-runtime + + + tomcat + jasper-compiler + + + commons-logging + commons-logging + + + tomcat + jasper-compiler-jdt + + + org.mortbay.jetty + jsp-api-2.0 + + + commons-el + commons-el + + + + + + + + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-jsp + + + + org.apache.tuscany.sca + helloworld-js-client + war + + helloworld-js-client + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-js-client/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..099b442050 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/pom.xml new file mode 100644 index 0000000000..36e71d4a88 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/pom.xml @@ -0,0 +1,130 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-jsf + Apache Tuscany SCA iTest Distribution Webapp helloworld-jsf + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-jsf + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + javax.el + el-api + 1.0 + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + jetty6x + embedded + + org.apache.commons.logging.impl.SimpleLog + + + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-jsf + + + + org.apache.tuscany.sca + helloworld-jsf + war + + helloworld-jsf + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsf/src/test/java/itest/HelloworldTestCaseFIXME.java new file mode 100644 index 0000000000..1f90a772ac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/pom.xml new file mode 100644 index 0000000000..62546a57a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/pom.xml @@ -0,0 +1,188 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-jsp + Apache Tuscany SCA iTest Distribution Webapp helloworld-jsp + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-jsp + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + org.mortbay.jetty + jsp-2.0 + 6.1.19 + pom + compile + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + + latest-jetty6x + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedLocalContainer + + embedded + + + + org.mortbay.jetty + jetty + + + org.mortbay.jetty + jetty-util + + + javax.servlet + servlet-api + + + org.mortbay.jetty + jsp-2.0 + + + tomcat + jasper-runtime + + + tomcat + jasper-compiler + + + commons-logging + commons-logging + + + tomcat + jasper-compiler-jdt + + + org.mortbay.jetty + jsp-api-2.0 + + + commons-el + commons-el + + + + + + + + org.codehaus.cargo.container.jetty.Jetty6xEmbeddedStandaloneLocalConfiguration + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-jsp + + + + org.apache.tuscany.sca + helloworld-jsp + war + + helloworld-jsp + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-jsp/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..2be60be081 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/pom.xml new file mode 100644 index 0000000000..a856894f4c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/pom.xml @@ -0,0 +1,124 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld-stripes + Apache Tuscany SCA iTest Distribution Webapp helloworld-stripes + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld-stripes + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + htmlunit + htmlunit + 1.9 + test + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + compile + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + jetty6x + embedded + + org.apache.commons.logging.impl.SimpleLog + + + + + ${project.build.directory}/cargo-jetty + + + + 8085 + helloworld-stripes + + + + org.apache.tuscany.sca + helloworld-stripes + war + + helloworld-stripes + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld-stripes/src/test/java/itest/HelloworldTestCase.java new file mode 100644 index 0000000000..743ab054c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld/pom.xml b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld/pom.xml new file mode 100644 index 0000000000..6a22b94775 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/distribution/webapp-helloworld/pom.xml @@ -0,0 +1,121 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + itest-distribution + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-distribution-webapp-helloworld + Apache Tuscany SCA iTest Distribution Webapp helloworld + + + + + org.apache.tuscany.sca + itest-bin-distro-unzip + pom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + helloworld + war + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + httpunit + httpunit + 1.6.1 + test + + + + + + + + org.codehaus.cargo + cargo-maven2-plugin + 1.0 + + + start-container + pre-integration-test + + start + + + + stop-container + post-integration-test + + stop + + + + + false + + jetty6x + embedded + + org.apache.commons.logging.impl.SimpleLog + + + + + ${project.build.directory}/cargo-jetty + + + + 8085 + + + + org.apache.tuscany.sca + helloworld + war + http://localhost:8085/helloworld + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/endpoints/pom.xml b/branches/sca-java-2.0-M4/itest/endpoints/pom.xml new file mode 100644 index 0000000000..4af0d2b6e5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/endpoints/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-endpoints + Apache Tuscany SCA iTest Endpoints + + + + + org.apache.tuscany.sca + tuscany-binding-jsonp-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c307547f56 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..064d615c45 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/EndpointsTestCase.java b/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/EndpointsTestCase.java new file mode 100644 index 0000000000..7802848c3b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP2() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP3() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP4() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP5() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP6() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo"); + } + + @Test + public void testWS1() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/WSComponent1/HelloWorldService"); + } + @Test + public void testWS2() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/WSComponent2/HelloWorldService/ws2"); + } + @Test + public void testWS3() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/WSComponent3/HelloWorldService/ws3"); + } + @Test + public void testWS4() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/ws4"); + } + @Test + public void testWS5() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/ws5b"); + } + @Test + public void testWS6() throws Exception { + // + 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/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java b/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/NestedEndpointsTestCase.java new file mode 100644 index 0000000000..f3b6c15bf1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent1/HelloWorldService/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP2() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent2/HelloWorldService/jsonp2/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP3() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent3/HelloWorldService/jsonp3/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP4() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp4/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP5() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/jsonp5b/sayHello?name=petra&callback=foo"); + } + @Test + public void testJSONP6() throws MalformedURLException, IOException { + // + Utils.invokeJSONPEndpoint("http://localhost:8085/NestedComponent1/JSONPComponent6/HelloWorldService/jsonp6a/jsonp6b/sayHello?name=petra&callback=foo"); + } + + @Test + public void testWS1() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent1/HelloWorldService"); + } + @Test + public void testWS2() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent2/HelloWorldService/ws2"); + } + @Test + public void testWS3() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/NestedComponent1/WSComponent3/HelloWorldService/ws3"); + } + @Test + public void testWS4() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/ws4"); + } + @Test + public void testWS5() throws MalformedURLException, Exception { + // + Utils.invokeWSEndpoint("http://localhost:8085/ws5b"); + } + @Test + public void testWS6() throws Exception { + // + 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/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/Utils.java b/branches/sca-java-2.0-M4/itest/endpoints/src/test/java/test/Utils.java new file mode 100644 index 0000000000..5107d8f660 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/helloworld.composite b/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/helloworld.composite new file mode 100644 index 0000000000..081804b34e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/helloworld.composite @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/nested.composite b/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/nested.composite new file mode 100644 index 0000000000..ffc73644f1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/endpoints/src/test/resources/nested.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/exceptions/pom.xml b/branches/sca-java-2.0-M4/itest/exceptions/pom.xml new file mode 100644 index 0000000000..bf50042468 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/exceptions/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-exceptions + Apache Tuscany SCA iTest Exceptions + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/Checked.java new file mode 100644 index 0000000000..1f57116bac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionHandler.java new file mode 100644 index 0000000000..112aefc747 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionRemoteThrower.java new file mode 100644 index 0000000000..53a6c70b57 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/ExceptionThrower.java new file mode 100644 index 0000000000..ace219991b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/UnChecked.java new file mode 100644 index 0000000000..453528444d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionHandlerImpl.java new file mode 100644 index 0000000000..26b9f0a383 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionRemoteThrowerImpl.java new file mode 100644 index 0000000000..cd62338841 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/ExceptionThrowerImpl.java new file mode 100644 index 0000000000..56b9fc6f5b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java b/branches/sca-java-2.0-M4/itest/exceptions/src/main/java/org/apache/tuscany/sca/test/exceptions/impl/RemoteExceptionHandlerImpl.java new file mode 100644 index 0000000000..c5b54ff902 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/exceptions/src/main/resources/ExceptionTest.composite b/branches/sca-java-2.0-M4/itest/exceptions/src/main/resources/ExceptionTest.composite new file mode 100644 index 0000000000..d42866303e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/exceptions/src/main/resources/ExceptionTest.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java b/branches/sca-java-2.0-M4/itest/exceptions/src/test/java/org/apache/tuscany/sca/test/exceptions/ExceptionsTestCase.java new file mode 100644 index 0000000000..7794348476 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/pom.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/pom.xml new file mode 100644 index 0000000000..9ed22005f5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-implementation-spring + Apache Tuscany SCA iTest Spring Implementation + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-spring-sca + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + + + org.springframework + spring-core + 2.5.5 + + + + org.springframework + spring-beans + 2.5.5 + + + + org.springframework + spring-context + 2.5.5 + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..bd7770ca7d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..747433a9e7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..eae607a7ca --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ce1cdaae5a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..b033516c1b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractService.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/CalculatorCallbackHandler.java new file mode 100644 index 0000000000..4f063993a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/JaasLoginModule.java new file mode 100644 index 0000000000..b3ef6e7312 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 sharedState, + Map 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; + } + } + + /** + *

This method is called if the LoginContext's + * overall authentication succeeded + * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules + * succeeded). + * + *

If this LoginModule's own authentication attempt + * succeeded (checked by retrieving the private state saved by the + * login method), then this method associates a + * UserPrincipal + * with the Subject located in the + * LoginModule. If this LoginModule's own + * authentication attempted failed, then this method removes + * any state that was originally saved. + * + *

+ * + * @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; + } + } + + /** + *

This method is called if the LoginContext's + * overall authentication failed. + * (the relevant REQUIRED, REQUISITE, SUFFICIENT and OPTIONAL LoginModules + * did not succeed). + * + *

If this LoginModule's own authentication attempt + * succeeded (checked by retrieving the private state saved by the + * login and commit methods), + * then this method cleans up any state that was originally saved. + * + *

+ * + * @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. + * + *

This method removes the SimplePrincipal + * that was added by the commit method. + * + *

+ * + * @exception LoginException if the logout fails. + * + * @return true in all cases since this LoginModule + * 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/calculator/security/UserPrincipal.java new file mode 100644 index 0000000000..595626e672 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/context/access/SCAApplicationContextProvider.java new file mode 100644 index 0000000000..fed509df98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..8bb3006d12 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..f68134702b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/helloworld/HelloWorldProxy.java new file mode 100644 index 0000000000..78b3649b5b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBean.java new file mode 100644 index 0000000000..1a0abd7f8f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestBeanImpl.java new file mode 100644 index 0000000000..e3d9a36bb8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestHelloWorldBean.java new file mode 100644 index 0000000000..47342fded8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReference.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReference.java new file mode 100644 index 0000000000..6f5b280f31 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestReferenceBean.java new file mode 100644 index 0000000000..dea7933e1a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/mock/TestSCAPropertyBean.java new file mode 100644 index 0000000000..b80b05dc08 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/java/spring/annotations/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ecb085858d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml new file mode 100644 index 0000000000..81d59432b8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/CalculatorService-context.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite new file mode 100644 index 0000000000..abdaa98bff --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/access/ContextAccess.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite new file mode 100644 index 0000000000..dd186bddfc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/ContextImports.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml new file mode 100644 index 0000000000..c50f0ef4d9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/CalculatorService-context.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml new file mode 100644 index 0000000000..a0bb10e8dd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/imports/META-INF/spring/SpringImport-context.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite new file mode 100644 index 0000000000..1c4b81db33 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/MultipleContext.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..9267f28e83 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/StockQuoteService-context.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml new file mode 100644 index 0000000000..dcc88f6770 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/context/multiple/springapp/META-INF/spring/beanRefContext.xml @@ -0,0 +1,34 @@ + + + + + + + + context/multiple/springapp/META-INF/spring/SpringHelloWorld-context.xml + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config new file mode 100644 index 0000000000..0e7cb86633 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorJass.config @@ -0,0 +1,3 @@ +Calculator { + calculator.security.JaasLoginModule required debug=true; +}; diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/CalculatorLogMessages.properties new file mode 100644 index 0000000000..0238f0b013 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite new file mode 100644 index 0000000000..1000e616a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/ImplementationPolicies.composite @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml new file mode 100644 index 0000000000..c50f0ef4d9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/META-INF/spring/CalculatorService-context.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml new file mode 100644 index 0000000000..278c94a18e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/implementation/policies/definitions.xml @@ -0,0 +1,40 @@ + + + + + + + + Calculator + calculator.security.CalculatorCallbackHandler + + + + + + + FINER + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite new file mode 100644 index 0000000000..2731fc455f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/SpringFolderLocation.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + Hello + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..950dbeba4c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/folder/springapp/META-INF/spring/SpringSCAProperty-context.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite new file mode 100644 index 0000000000..e8357cc62e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/SpringJarLocation.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + Hello + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar new file mode 100644 index 0000000000..504d59e5ff Binary files /dev/null and b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/location/jar/spring-context.jar differ diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringDelegationHelloWorld-context.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/META-INF/spring/SpringHelloWorld-context.xml @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite new file mode 100644 index 0000000000..b8389be7f6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite new file mode 100644 index 0000000000..8d1a655c4e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/org/apache/tuscany/sca/itest/spring/SpringHelloWorld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml new file mode 100644 index 0000000000..1705164104 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringExplicitReference-context.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml new file mode 100644 index 0000000000..539dfa6e32 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/META-INF/spring/SpringImplicitReference-context.xml @@ -0,0 +1,34 @@ + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite new file mode 100644 index 0000000000..294b211431 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringExplicitReference.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite new file mode 100644 index 0000000000..c77ab00323 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/references/SpringImplicitReference.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml new file mode 100644 index 0000000000..42e0cdbd23 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringExplicitService-context.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml new file mode 100644 index 0000000000..83558e8abc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/META-INF/spring/SpringImplicitService-context.xml @@ -0,0 +1,31 @@ + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite new file mode 100644 index 0000000000..b7c45b289f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringExplicitService.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite new file mode 100644 index 0000000000..e1ccbcf3c6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/sca/services/SpringImplicitService.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite new file mode 100644 index 0000000000..236e2b23e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/Calculator.composite @@ -0,0 +1,60 @@ + + + + + + + HelloWorld + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml new file mode 100644 index 0000000000..4a873f2424 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/implementation-spring/src/main/resources/spring/annotations/CalculatorService-context.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/CalculatorClient.java new file mode 100644 index 0000000000..4503294f10 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/access/ContextAccessTestCase.java new file mode 100644 index 0000000000..2602839d1d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/CalculatorClient.java new file mode 100644 index 0000000000..254b8100e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/imports/ContextImportsTestCase.java new file mode 100644 index 0000000000..8df60c5bab --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/MultipleContextTestCase.java new file mode 100644 index 0000000000..f5261c85bb --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/context/multiple/StockQuoteServer.java new file mode 100644 index 0000000000..9ff1b74567 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/CalculatorClient.java new file mode 100644 index 0000000000..8b12dd7af7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/implementation/policies/ImplementationPoliciesTestCase.java new file mode 100644 index 0000000000..a44ae38d24 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/folder/SpringFolderLocationTestCase.java new file mode 100644 index 0000000000..d54f0544d8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/location/jar/SpringJarLocationTestCase.java new file mode 100644 index 0000000000..71768f5a7b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractHelloWorldTestCase.java new file mode 100644 index 0000000000..0c6f8d2e84 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + /** + * 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 getServiceClass() { + return HelloWorld.class; + } +} diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/AbstractSCATestCase.java new file mode 100644 index 0000000000..73b151bf7a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 getServiceClass(); + + @Override + protected void tearDown() throws Exception { + node.stop(); + } +} diff --git a/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorld.java new file mode 100644 index 0000000000..5869d344f6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/HelloWorldProxy.java new file mode 100644 index 0000000000..90d26dd89f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringDelegationHelloWorldTestCase.java new file mode 100644 index 0000000000..f28dace31a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/SpringHelloWorldTestCase.java new file mode 100644 index 0000000000..def30b3ea0 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldBean.java new file mode 100644 index 0000000000..fa7967c964 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/org/apache/tuscany/sca/itest/spring/TestHelloWorldDelegatorBean.java new file mode 100644 index 0000000000..b57cc7f366 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringExplicitReferenceTestCase.java new file mode 100644 index 0000000000..0c2e1daa81 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/references/SpringImplicitReferenceTestCase.java new file mode 100644 index 0000000000..8d0c548899 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringExplicitServiceTestCase.java new file mode 100644 index 0000000000..f4bd53876c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/sca/services/SpringImplicitServiceTestCase.java new file mode 100644 index 0000000000..0907985d7f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/CalculatorClient.java new file mode 100644 index 0000000000..13b84c8c73 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java b/branches/sca-java-2.0-M4/itest/implementation-spring/src/test/java/spring/annotations/SpringAnnotationsTestCase.java new file mode 100644 index 0000000000..5db9c84c00 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/pom.xml b/branches/sca-java-2.0-M4/itest/interfaces/pom.xml new file mode 100644 index 0000000000..ea2199f7fe --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/interfaces/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-interfaces + Apache Tuscany SCA iTest Interface + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalCallbackInterface.java new file mode 100644 index 0000000000..f4131593d5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponent.java new file mode 100644 index 0000000000..5fc9ed51b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalClientComponentImpl.java new file mode 100644 index 0000000000..6cd937af12 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponent.java new file mode 100644 index 0000000000..05a9d09bdd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/LocalServiceComponentImpl.java new file mode 100644 index 0000000000..ab0b18191c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/ParameterObject.java new file mode 100644 index 0000000000..724d94dffb --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteCallbackInterface.java new file mode 100644 index 0000000000..be3fa4c15a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponent.java new file mode 100644 index 0000000000..9f34dfd274 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java new file mode 100644 index 0000000000..541b1f1508 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponent.java new file mode 100644 index 0000000000..b29b298ab6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java b/branches/sca-java-2.0-M4/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteServiceComponentImpl.java new file mode 100644 index 0000000000..00a0f5645b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InterfacesTest.composite b/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InterfacesTest.composite new file mode 100644 index 0000000000..27ada047b9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InterfacesTest.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite b/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite new file mode 100644 index 0000000000..c91d49a49a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/interfaces/src/main/resources/InvalidRemoteAttribute.composite @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java b/branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java new file mode 100644 index 0000000000..31e40d59c5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java b/branches/sca-java-2.0-M4/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InvalidRemoteAttributeTestCase.java new file mode 100644 index 0000000000..b1d4dba07d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/pom.xml b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/pom.xml new file mode 100644 index 0000000000..1312122789 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jaxws-asyncclient + Apache Tuscany JAX-WS Integration Tests + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + diff --git a/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuote.java new file mode 100644 index 0000000000..4e55bae98d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteClient.java new file mode 100644 index 0000000000..0bf3328c31 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 response = stockQuote.getPriceAsync("foo"); + return response.get(); + } + + float price = 0f; + Object mutex = new Object(); + Exception exception; + + public float getPriceAsyncCallback(String ticker) throws Exception { + AsyncHandler callback = new AsyncHandler() { + public void handleResponse(Response 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/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteImpl.java new file mode 100644 index 0000000000..a43b85361b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/java/stock/StockQuoteRef.java new file mode 100644 index 0000000000..b15ab6be08 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPriceAsync(String ticker); + + Future getPriceAsync(String ticker, AsyncHandler callback); +} diff --git a/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..11ace7a788 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..313edf0435 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/main/resources/StockQuote.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java b/branches/sca-java-2.0-M4/itest/jaxws-asyncclient/src/test/java/itest/AsyncServiceTestCase.java new file mode 100644 index 0000000000..eb72924093 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jaxws/pom.xml b/branches/sca-java-2.0-M4/itest/jaxws/pom.xml new file mode 100644 index 0000000000..94b85e5b9d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jaxws/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jaxws + Apache Tuscany JAX-WS Integration Tests + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + junit + junit + 4.5 + test + + + diff --git a/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java b/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/AsyncServiceTestCase.java new file mode 100644 index 0000000000..e1c2bedea3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuote.java b/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuote.java new file mode 100644 index 0000000000..74e25bb3bd --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPriceAsync(String ticker); + + Future getPriceAsync(String ticker, AsyncHandler callback); + + +} diff --git a/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuoteImpl.java b/branches/sca-java-2.0-M4/itest/jaxws/src/test/java/stock/StockQuoteImpl.java new file mode 100644 index 0000000000..516c63d864 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPriceAsync(String ticker) { + return null; + } + + public Future getPriceAsync(String ticker, AsyncHandler callback) { + return null; + } + +} diff --git a/branches/sca-java-2.0-M4/itest/jaxws/src/test/resources/StockQuote.composite b/branches/sca-java-2.0-M4/itest/jaxws/src/test/resources/StockQuote.composite new file mode 100644 index 0000000000..b2c9bd8ddb --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jaxws/src/test/resources/StockQuote.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/pom.xml b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/pom.xml new file mode 100644 index 0000000000..8e2000b2c6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-dynamic-replyq + Apache Tuscany SCA iTest JMS with dynamic replyq + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..9aef6ba1a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..a9d43b5637 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite new file mode 100644 index 0000000000..cbad991ac5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/dynamic/client.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite new file mode 100644 index 0000000000..01553a968c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/main/resources/simple/service.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java b/branches/sca-java-2.0-M4/itest/jms/DynamicReplyQ/src/test/java/org/apache/tuscany/sca/binding/jms/DynamicReplyQTestCase.java new file mode 100644 index 0000000000..3bf4e0bc30 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/args/pom.xml b/branches/sca-java-2.0-M4/itest/jms/args/pom.xml new file mode 100644 index 0000000000..b2f49c91e2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/args/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-args + Apache Tuscany SCA iTest JMS Args + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + + org.apache.activemq + activemq-core + 5.2.0 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..68506b857b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java new file mode 100644 index 0000000000..5f19aa1fa5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/args/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java new file mode 100644 index 0000000000..18324d5d1d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..07caa57490 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/selectors/selectors.composite b/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/selectors/selectors.composite new file mode 100644 index 0000000000..1a9075f6d4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/args/src/main/resources/selectors/selectors.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/args/src/test/java/org/apache/tuscany/sca/binding/jms/ArgsTestCase.java new file mode 100644 index 0000000000..28e0b530c1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/pom.xml b/branches/sca-java-2.0-M4/itest/jms/callbacks/pom.xml new file mode 100644 index 0000000000..1f6a27cb53 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/callbacks/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-jms-callbacks + Apache Tuscany SCA iTest JMS Tests For Callbacks + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.2.0 + test + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java new file mode 100644 index 0000000000..d4cd5df431 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClientImpl.java new file mode 100644 index 0000000000..a4d5190af3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSService.java new file mode 100644 index 0000000000..b78feab413 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceCallback.java new file mode 100644 index 0000000000..20b74ccc1a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/java/org/apache/tuscany/sca/binding/jms/JMSServiceImpl.java new file mode 100644 index 0000000000..e8357338ae --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..95c3a41c43 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/jndi.properties new file mode 100644 index 0000000000..dec266b133 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/client.composite b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/client.composite new file mode 100644 index 0000000000..19124fc3e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/client.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/tempq.composite b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/tempq.composite new file mode 100644 index 0000000000..5ef7c981f0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/main/resources/simple/tempq.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/CallbackTestCase.java new file mode 100644 index 0000000000..18911ad8b6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java b/branches/sca-java-2.0-M4/itest/jms/callbacks/src/test/java/org/apache/tuscany/sca/binding/jms/TempCallbackQTestCase.java new file mode 100644 index 0000000000..b335add358 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/defaults/pom.xml b/branches/sca-java-2.0-M4/itest/jms/defaults/pom.xml new file mode 100644 index 0000000000..3d85dbd021 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/defaults/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-defaults + Apache Tuscany SCA iTest JMS with Defaults + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..9aef6ba1a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2a74e465ea --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/client.composite b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/client.composite new file mode 100644 index 0000000000..c4d5215f86 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/client.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/service.composite b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/service.composite new file mode 100644 index 0000000000..a4de896f24 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/defaults/service.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/defaults/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/defaults/src/test/java/org/apache/tuscany/sca/binding/jms/DefaultsTestCase.java new file mode 100644 index 0000000000..d2b1a5fe59 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/definitions/pom.xml b/branches/sca-java-2.0-M4/itest/jms/definitions/pom.xml new file mode 100644 index 0000000000..29bc1068a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/definitions/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-definitions + Apache Tuscany SCA iTest JMS Tests For Properties + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + + org.apache.activemq + activemq-core + 5.2.0 + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..b572b1012a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..9cec2d9b3e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..6b763874df --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..07caa57490 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions.xml b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions.xml new file mode 100644 index 0000000000..07b9f4aaa8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions.xml @@ -0,0 +1,28 @@ + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions/definitions.composite b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions/definitions.composite new file mode 100644 index 0000000000..67a62a7165 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/definitions/definitions.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/definitions/src/main/resources/jndi.properties new file mode 100644 index 0000000000..f7555e0beb --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/definitions/src/test/java/org/apache/tuscany/sca/binding/jms/DefinitionsTestCase.java new file mode 100644 index 0000000000..729ad072b7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/pom.xml b/branches/sca-java-2.0-M4/itest/jms/exceptions/pom.xml new file mode 100644 index 0000000000..06283c6b55 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions/pom.xml @@ -0,0 +1,90 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-nonscaclient-exceptions + Apache Tuscany SCA iTest JMS NonSCA Client Exceptions + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + xmlunit + xmlunit + 1.2 + test + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java new file mode 100644 index 0000000000..469882f3b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java new file mode 100644 index 0000000000..19b584950a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java new file mode 100644 index 0000000000..b12e3a562e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java new file mode 100644 index 0000000000..b23db73c01 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java new file mode 100644 index 0000000000..9e4c4c46d4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java new file mode 100644 index 0000000000..866acf1ce1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c9945cc57d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/exceptions/service.composite b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/exceptions/service.composite new file mode 100644 index 0000000000..9eb8f2b27d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/exceptions/service.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/main/resources/jndi.properties new file mode 100644 index 0000000000..72d5457faf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java new file mode 100644 index 0000000000..1e1a0987ad --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = + "foo"; + private static final String CHECKED_NOARGS_XML = ""; + private static final String CHECKED_2ARGS_XML = + "foo"; + private static final String CHECKED_CHAINED_XML = + "java.lang.Exception: bla"; + + @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/branches/sca-java-2.0-M4/itest/jms/exceptions1/pom.xml b/branches/sca-java-2.0-M4/itest/jms/exceptions1/pom.xml new file mode 100644 index 0000000000..c7c4fac108 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions1/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-exceptions1 + Apache Tuscany SCA iTest JMS with Exceptions1 + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion.java new file mode 100644 index 0000000000..469882f3b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetion2Args.java new file mode 100644 index 0000000000..19b584950a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionChained.java new file mode 100644 index 0000000000..b12e3a562e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/CheckedExcpetionNoArgs.java new file mode 100644 index 0000000000..b23db73c01 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionService.java new file mode 100644 index 0000000000..9e4c4c46d4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceClient.java new file mode 100644 index 0000000000..02426936d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/java/org/apache/tuscany/sca/binding/jms/ExceptionServiceImpl.java new file mode 100644 index 0000000000..866acf1ce1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c28c94da98 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/client.composite b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/client.composite new file mode 100644 index 0000000000..5d1c57a1f3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/client.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/service.composite b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/service.composite new file mode 100644 index 0000000000..6875772d56 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/exceptions/service.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/ExceptionsTestCase.java new file mode 100644 index 0000000000..170e28b15d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/externalBroker/pom.xml b/branches/sca-java-2.0-M4/itest/jms/externalBroker/pom.xml new file mode 100644 index 0000000000..b256fc1488 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/externalBroker/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-external-broker + Apache Tuscany SCA iTest JMS with External JMS Broker + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..9aef6ba1a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..60b132ca1b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/client.composite b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/client.composite new file mode 100644 index 0000000000..cad76ef45f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/client.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/service.composite b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/service.composite new file mode 100644 index 0000000000..8a76d8cd29 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/external/service.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java b/branches/sca-java-2.0-M4/itest/jms/externalBroker/src/test/java/org/apache/tuscany/sca/binding/jms/ExternalBrokerTestCase.java new file mode 100644 index 0000000000..b8cbde7b26 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/pom.xml new file mode 100644 index 0000000000..abe5f116e7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmsbytes + Apache Tuscany SCA iTest JMS Message Format jmsbytes + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite new file mode 100644 index 0000000000..e5a904871c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jmsbytes/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytes/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/pom.xml new file mode 100644 index 0000000000..a816f8a234 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmsbytesxml + Apache Tuscany SCA iTest JMS Message Format jmsbytesxml + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite new file mode 100644 index 0000000000..a28e6e5f6d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jmsbytesxml/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSBytesXMLTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsbytesxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/pom.xml new file mode 100644 index 0000000000..36e27c2f63 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmsdefault + Apache Tuscany SCA iTest JMS Message Format jmsdefault + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite new file mode 100644 index 0000000000..a6d6e04ac8 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.composite @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl new file mode 100644 index 0000000000..935a2e73c5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jmsdefault/helloworld.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsdefault/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSDefaultTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/pom.xml new file mode 100644 index 0000000000..5014c594b6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmsmessage + Apache Tuscany SCA iTest JMS Message Format jmsmessage + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite new file mode 100644 index 0000000000..c624a11233 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl new file mode 100644 index 0000000000..f72ce434fa --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jmsmessage/helloworld.wsdl @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsmessage/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSMessageTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/pom.xml new file mode 100644 index 0000000000..66216aeeec --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmsobject + Apache Tuscany SCA iTest JMS Message Format jmsobject + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite new file mode 100644 index 0000000000..e037aa74d9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.composite @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl new file mode 100644 index 0000000000..4625f46578 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jmsobject/helloworld.wsdl @@ -0,0 +1,368 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmsobject/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSObjectTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/pom.xml new file mode 100644 index 0000000000..8a34f85c33 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmstext + Apache Tuscany SCA iTest JMS Message Format jmstext + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite new file mode 100644 index 0000000000..d700a92f20 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jmstext/helloworld.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstext/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/pom.xml new file mode 100644 index 0000000000..a792f6c608 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmstextxml + Apache Tuscany SCA iTest JMS Message Format jmstextxml + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite new file mode 100644 index 0000000000..72e7646704 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.composite @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl new file mode 100644 index 0000000000..53db66ea7e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jmstextxml/helloworld.wsdl @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxml/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml new file mode 100644 index 0000000000..38b53d7f73 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-format-jmstextxmlinjmsobjectout + Apache Tuscany SCA iTest JMS Message Format jmstextxmlinjmsobjectout + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytes/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsbytesxml/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsdefault/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/HelloWorldServiceReferenceSide.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsmessage/helloworld/README b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmsobject/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstext/helloworld/HelloWorldServiceReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/CheckedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxml/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/java/org/apache/tuscany/sca/binding/jms/format/jmstextxmlinjmsobjectout/helloworld/Person.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..84ac2356db --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite new file mode 100644 index 0000000000..b8bc67d5e3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.composite @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl new file mode 100644 index 0000000000..935a2e73c5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jmstextxmlinjmsobjectout/helloworld.wsdl @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/format-jmstextxmlinjmsobjectout/src/test/java/org/apache/tuscany/sca/binding/jms/format/FormatJMSTextXMLInJMSObjectOutTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/pom.xml b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/pom.xml new file mode 100644 index 0000000000..38f757160f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-non-sca-client-broker + Apache Tuscany SCA iTest JMS with Non SCA Client + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..90106d2cbf --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite new file mode 100644 index 0000000000..967754b6e4 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/main/resources/nonSCAclient/service.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/non-sca-client/src/test/java/org/apache/tuscany/sca/binding/jms/NonSCAClientTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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", "Petra"); + + // 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 arg = new HashSet(); + 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/branches/sca-java-2.0-M4/itest/jms/noreplyto/pom.xml b/branches/sca-java-2.0-M4/itest/jms/noreplyto/pom.xml new file mode 100644 index 0000000000..f6e0076157 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/noreplyto/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-noreplyto + Apache Tuscany SCA iTest JMS No replyTo + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..58ceeded7e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/service.composite b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/service.composite new file mode 100644 index 0000000000..86bb60c147 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/main/resources/service.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java b/branches/sca-java-2.0-M4/itest/jms/noreplyto/src/test/java/org/apache/tuscany/sca/binding/jms/NoReplyToTestCase.java new file mode 100644 index 0000000000..848e340181 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/nulls/pom.xml b/branches/sca-java-2.0-M4/itest/jms/nulls/pom.xml new file mode 100644 index 0000000000..98480566e5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/nulls/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-nulls + Apache Tuscany SCA iTest JMS Nulls + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.activemq + activemq-core + 5.2.0 + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..7fed36fa77 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/MyService.java new file mode 100644 index 0000000000..7ab6019fd5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/java/org/apache/tuscany/sca/binding/jms/ServiceImpl.java new file mode 100644 index 0000000000..89758becff --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..eee9c86565 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/nulls.composite b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/nulls.composite new file mode 100644 index 0000000000..e190cf92c9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/nulls/src/main/resources/nulls.composite @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/nulls/src/test/java/org/apache/tuscany/sca/binding/jms/NullsTestCase.java new file mode 100644 index 0000000000..ac872f46a6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/pom.xml b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/pom.xml new file mode 100644 index 0000000000..bf4625fb3e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-jms-oneway-nocf + Apache Tuscany SCA iTest JMS for a oneway service + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..360b365d1b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/jndi.properties new file mode 100644 index 0000000000..8934614a8a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite new file mode 100644 index 0000000000..70a106bf06 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayClient.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite new file mode 100644 index 0000000000..5412a1d6e0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/main/resources/oneway/OneWayService.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway-nocf/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/pom.xml b/branches/sca-java-2.0-M4/itest/jms/oneway/pom.xml new file mode 100644 index 0000000000..edf0c10b39 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-oneway + Apache Tuscany SCA iTest JMS with Oneway + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..b572b1012a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectService.java new file mode 100644 index 0000000000..9083ba1d9c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayObjectServiceImpl.java new file mode 100644 index 0000000000..3149f99a25 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..9cec2d9b3e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..0036391696 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..360b365d1b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite new file mode 100644 index 0000000000..eeeb3b90d0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayClient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite new file mode 100644 index 0000000000..e41e226994 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/oneway/src/main/resources/oneway/OneWayService.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java b/branches/sca-java-2.0-M4/itest/jms/oneway/src/test/java/org/apache/tuscany/sca/binding/jms/OneWayTestCase.java new file mode 100644 index 0000000000..14bbf238e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/pom.xml b/branches/sca-java-2.0-M4/itest/jms/policy-headers/pom.xml new file mode 100644 index 0000000000..eef6c9b359 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/policy-headers/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-policy-headers + Apache Tuscany SCA iTest JMS with Policy Headers + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..a930b9e9a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml new file mode 100644 index 0000000000..8c608adec9 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/definitions.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite new file mode 100644 index 0000000000..f2761f0b78 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/main/resources/policyHeaders/policyHeaders.composite @@ -0,0 +1,45 @@ + + + + + + + + + + myHeadP1 + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/policy-headers/src/test/java/org/apache/tuscany/sca/binding/jms/PolicyHeadersTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/pom.xml b/branches/sca-java-2.0-M4/itest/jms/pom.xml new file mode 100644 index 0000000000..3e7815da0c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + pom + itest-jms + Apache Tuscany SCA iTest JMS + + + args + defaults + DynamicReplyQ + exceptions + exceptions1 + externalBroker + format-jmsbytes + format-jmsbytesxml + format-jmsdefault + format-jmsmessage + format-jmsobject + format-jmstext + format-jmstextxml + format-jmstextxmlinjmsobjectout + non-sca-client + noreplyto + nulls + oneway + oneway-nocf + policy-headers + properties + responsecf + rpc + selectors + topics + ttl + uri-rpc + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/properties/pom.xml b/branches/sca-java-2.0-M4/itest/jms/properties/pom.xml new file mode 100644 index 0000000000..43d8b3c3fe --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/properties/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-properties + Apache Tuscany SCA iTest JMS with Properties + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/JMSClient.java new file mode 100644 index 0000000000..d4cd5df431 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClient.java new file mode 100644 index 0000000000..464072b42d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientImpl.java new file mode 100644 index 0000000000..4140fa0b89 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgClientService.java new file mode 100644 index 0000000000..2be4f2ad3e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgService.java new file mode 100644 index 0000000000..d5684ca56c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/java/org/apache/tuscany/sca/binding/jms/MsgServiceImpl.java new file mode 100644 index 0000000000..e18de0456c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..a930b9e9a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/properties/properties.composite b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/properties/properties.composite new file mode 100644 index 0000000000..73f2a8eadc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/properties/src/main/resources/properties/properties.composite @@ -0,0 +1,53 @@ + + + + + + + + + + myHeadP1 + + + + foo + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java b/branches/sca-java-2.0-M4/itest/jms/properties/src/test/java/org/apache/tuscany/sca/binding/jms/PropertiesTestCase.java new file mode 100644 index 0000000000..29d5a345b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/responsecf/pom.xml b/branches/sca-java-2.0-M4/itest/jms/responsecf/pom.xml new file mode 100644 index 0000000000..1caa55460a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/responsecf/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-responsecf + Apache Tuscany SCA iTest JMS Response ConnectionFactory + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..9aef6ba1a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c062ef9ec0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/client.composite b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/client.composite new file mode 100644 index 0000000000..3a03f9b675 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/client.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/service.composite b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/service.composite new file mode 100644 index 0000000000..d7ba8f2838 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/cf/service.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/main/resources/jndi.properties new file mode 100644 index 0000000000..a41e42950e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java b/branches/sca-java-2.0-M4/itest/jms/responsecf/src/test/java/org/apache/tuscany/sca/binding/jms/ResponseCFTestCase.java new file mode 100644 index 0000000000..03b834ce7d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/rpc/pom.xml b/branches/sca-java-2.0-M4/itest/jms/rpc/pom.xml new file mode 100644 index 0000000000..3c38e20e6f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/rpc/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-rpc + Apache Tuscany SCA iTest JMS with RPC + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java new file mode 100644 index 0000000000..9aef6ba1a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java new file mode 100644 index 0000000000..430c71aaef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..2c6d9d0d17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c062ef9ec0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/client.composite b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/client.composite new file mode 100644 index 0000000000..bed860e2cd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/client.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/service.composite b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/service.composite new file mode 100644 index 0000000000..01553a968c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/rpc/src/main/resources/simple/service.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java b/branches/sca-java-2.0-M4/itest/jms/rpc/src/test/java/org/apache/tuscany/sca/binding/jms/RPCTestCase.java new file mode 100644 index 0000000000..3c0eb0791b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/pom.xml b/branches/sca-java-2.0-M4/itest/jms/selectors/pom.xml new file mode 100644 index 0000000000..0cf3c4d2cb --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/selectors/pom.xml @@ -0,0 +1,70 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-selectors + Apache Tuscany SCA iTest JMS Tests For Selectors + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..b589d5e8bc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorService.java new file mode 100644 index 0000000000..1aff0d454e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl1.java new file mode 100644 index 0000000000..fb53c877e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 names = new ArrayList(); + + 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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl2.java new file mode 100644 index 0000000000..1bbaf5d6f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/SelectorServiceImpl3.java new file mode 100644 index 0000000000..4bdc4edcb5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldReferenceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..59cf4aee9d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite new file mode 100644 index 0000000000..ab8e29ccdd --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsdefault/helloworld.composite @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + getGreetingsThree + + + + + + + + + + + + + + getGreetingsThree + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite new file mode 100644 index 0000000000..af36b8af9b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jmsuserprop/helloworld.composite @@ -0,0 +1,65 @@ + + + + + + + + + + + + getGreetingsOne + + + + + getGreetingsThree + + + + + getGreetingsTwo + + + + + + + + + + + + + + getGreetingsThree + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/jndi.properties new file mode 100644 index 0000000000..bb431a592b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/selectors/selectors.composite b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/selectors/selectors.composite new file mode 100644 index 0000000000..bf10f20d38 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/selectors/src/main/resources/selectors/selectors.composite @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSDefaultTestCase.java new file mode 100644 index 0000000000..bee0c549bd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/OperationselectorJMSUserPropTestCase.java new file mode 100644 index 0000000000..33e047ae18 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/selectors/src/test/java/org/apache/tuscany/sca/binding/jms/SelectorsTestCase.java new file mode 100644 index 0000000000..e7254005be --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/topics/pom.xml b/branches/sca-java-2.0-M4/itest/jms/topics/pom.xml new file mode 100644 index 0000000000..47ec58acdf --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/topics/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-topics + Apache Tuscany SCA JMS Tests for topics + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + test + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayClientImpl.java new file mode 100644 index 0000000000..b572b1012a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayService.java new file mode 100644 index 0000000000..9cec2d9b3e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/java/org/apache/tuscany/sca/binding/jms/OneWayServiceImpl.java new file mode 100644 index 0000000000..0036391696 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2690297524 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/jndi.properties new file mode 100644 index 0000000000..9888d5843b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsClient.composite b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsClient.composite new file mode 100644 index 0000000000..b951484044 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsClient.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsService.composite b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsService.composite new file mode 100644 index 0000000000..80c653cc29 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/topics/src/main/resources/topics/TopicsService.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java b/branches/sca-java-2.0-M4/itest/jms/topics/src/test/java/org/apache/tuscany/sca/binding/jms/TopicsTestCase.java new file mode 100644 index 0000000000..35fe96b81a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/ttl/pom.xml b/branches/sca-java-2.0-M4/itest/jms/ttl/pom.xml new file mode 100644 index 0000000000..ac8e5c5291 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/ttl/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-ttl + Apache Tuscany SCA iTest JMS Time To Live + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.activemq + activemq-core + 5.2.0 + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/itest/MockInitialContextFactory.java new file mode 100644 index 0000000000..336fecf67b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 list(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration list(String name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration listBindings(Name name) throws NamingException { + // TODO Auto-generated method stub + return null; + } + + public NamingEnumeration 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/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientIface.java new file mode 100644 index 0000000000..dc6577b7e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/java/org/apache/tuscany/sca/binding/jms/ClientImpl.java new file mode 100644 index 0000000000..4f9908f062 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..eeae8fcc59 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/jndi.properties new file mode 100644 index 0000000000..040ec282d7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/ttl.composite b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/ttl.composite new file mode 100644 index 0000000000..91b64cf8dc --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/ttl/src/main/resources/ttl.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java b/branches/sca-java-2.0-M4/itest/jms/ttl/src/test/java/org/apache/tuscany/sca/binding/jms/TTLTestCase.java new file mode 100644 index 0000000000..b5839f4c4f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/uri-rpc/pom.xml b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/pom.xml new file mode 100644 index 0000000000..6edb521611 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/pom.xml @@ -0,0 +1,83 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-jms-uri-rpc + Apache Tuscany SCA iTest JMS with URI RPC + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jms-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.activemq + activemq-core + 5.2.0 + runtime + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + ${artifactId} + + diff --git a/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3349754e4a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/jndi.properties b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/jndi.properties new file mode 100644 index 0000000000..4d6acc037b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/service.composite b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/service.composite new file mode 100644 index 0000000000..01553a968c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/service.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite new file mode 100644 index 0000000000..9e7b119fad --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/main/resources/simple/uriclient.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/jms/uri-rpc/src/test/java/org/apache/tuscany/sca/binding/jms/URIRPCTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml new file mode 100644 index 0000000000..13b0dd0ab2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/pom.xml @@ -0,0 +1,44 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-helloworld-client + Apache Tuscany SCA iTest Nodes Helloworld Client + + + + org.apache.tuscany.sca + itest-nodes-helloworld-iface + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + provided + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/java/itest/nodes/HelloworldImpl.java new file mode 100644 index 0000000000..bf8a588928 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b4ba94220c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite new file mode 100644 index 0000000000..9d5e9ae59a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-client/src/main/resources/helloworld-client.composite @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml new file mode 100644 index 0000000000..b8c8205eb2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-helloworld-iface + Apache Tuscany SCA iTest Nodes Helloworld IFaces + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + provided + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java b/branches/sca-java-2.0-M4/itest/nodes/helloworld-iface/src/main/java/itest/nodes/Helloworld.java new file mode 100644 index 0000000000..76f8d4400d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml new file mode 100644 index 0000000000..a8fe3ff7b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/pom.xml @@ -0,0 +1,49 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-helloworld-service + Apache Tuscany SCA iTest Nodes Helloworld Service + + + + org.apache.tuscany.sca + itest-nodes-helloworld-iface + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + provided + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/java/itest/nodes/HelloworldImpl.java new file mode 100644 index 0000000000..81f7e1747d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c65718909d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite new file mode 100644 index 0000000000..6b2d15b7a6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/helloworld-service/src/main/resources/helloworld-service.composite @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml new file mode 100644 index 0000000000..0eb49a19fe --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/one-node-test/pom.xml @@ -0,0 +1,48 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-one-node-test + Apache Tuscany SCA iTest Nodes One Node Test + + + + org.apache.tuscany.sca + itest-nodes-helloworld-iface + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java b/branches/sca-java-2.0-M4/itest/nodes/one-node-test/src/test/java/itest/OneNodeTestCase.java new file mode 100644 index 0000000000..6d49b718ef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/pom.xml new file mode 100644 index 0000000000..0ef109c44e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + pom + itest-nodes + Apache Tuscany SCA iTest Nodes + + + install + + + + helloworld-iface + helloworld-service + helloworld-client + one-node-test + two-nodes-test + two-nodes-two-vms-test + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml new file mode 100644 index 0000000000..f5c6d11cda --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/pom.xml @@ -0,0 +1,58 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-two-nodes-test + Apache Tuscany SCA iTest Nodes Two Nodes Test + + + + org.apache.tuscany.sca + itest-nodes-helloworld-iface + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-sca-client-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ClientNode.java new file mode 100644 index 0000000000..5f9453a5d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/ServiceNode.java new file mode 100644 index 0000000000..b413825106 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/StopStartNodesTestCase.java new file mode 100644 index 0000000000..4a41ae8133 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TestCaseRunner.java new file mode 100644 index 0000000000..7dfa6e66cc --- /dev/null +++ b/branches/sca-java-2.0-M4/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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + 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() { + public Object run() { + Thread.currentThread().setContextClassLoader(finaltccl); + return null; + } + }); + } + } + +} + diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-test/src/test/java/itest/TwoNodesTestCase.java new file mode 100644 index 0000000000..769aad1940 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml new file mode 100644 index 0000000000..933aec2636 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/build.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml new file mode 100644 index 0000000000..1bda0ee4b7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client-config.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml new file mode 100644 index 0000000000..bb65805144 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/client.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml new file mode 100644 index 0000000000..34eadae505 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-nodes-two-nodes-two-vms-test + Apache Tuscany SCA iTest Nodes Two Nodes Two VMs Test + + + + org.apache.tuscany.sca + tuscany-endpoint-tribes + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + itest-nodes-helloworld-iface + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-launcher + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-sca-client-impl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2-runtime + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.3 + + + + ant + ant-trax + 1.6.5 + + + + sun.jdk + tools + 1.6 + system + ${java.home}/../lib/tools.jar + + + + + + run-samples + verify + + run + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml new file mode 100644 index 0000000000..14a48f507a --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server-config.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml new file mode 100644 index 0000000000..7b6d206b7f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/server.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java b/branches/sca-java-2.0-M4/itest/nodes/two-nodes-two-vms-test/src/test/java/itest/TwoNodesTestCase.java new file mode 100644 index 0000000000..b27d16a562 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/operation-overloading/pom.xml b/branches/sca-java-2.0-M4/itest/operation-overloading/pom.xml new file mode 100644 index 0000000000..cd646e490d --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/operation-overloading/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-operation-overloading + Apache Tuscany SCA iTest Operation Overloading + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java b/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/OverloadASourceTarget.java new file mode 100644 index 0000000000..1f589b44f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadASource.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 ret = new ArrayList(); + 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/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATarget.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/resources/OperationOverload.composite b/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/resources/OperationOverload.composite new file mode 100644 index 0000000000..cbf5aa2078 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/operation-overloading/src/main/resources/OperationOverload.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/operation-overloading/src/test/java/org/apache/tuscany/sca/test/opoverload/impl/OverloadATestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/pom.xml b/branches/sca-java-2.0-M4/itest/policies/pom.xml new file mode 100644 index 0000000000..af385501ab --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/policies/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-policies + Apache Tuscany SCA iTest Policies + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy-logging + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCard.java new file mode 100644 index 0000000000..fd33be01d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CreditCardPayment.java new file mode 100644 index 0000000000..368179dc29 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Customer.java new file mode 100644 index 0000000000..05ea341466 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/CustomerRegistry.java new file mode 100644 index 0000000000..c9f50d08ee --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/Payment.java new file mode 100644 index 0000000000..cc7c555aff --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CreditCardPaymentImpl.java new file mode 100644 index 0000000000..01cc8ac636 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/CustomerRegistryImpl.java new file mode 100644 index 0000000000..943720451f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 customers = new HashMap(); + + + @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/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java b/branches/sca-java-2.0-M4/itest/policies/src/main/java/org/apache/tuscany/sca/itest/policies/impl/PaymentImpl.java new file mode 100644 index 0000000000..b712b99388 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Customer.composite b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Customer.composite new file mode 100644 index 0000000000..2a8f598b90 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Customer.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/policies/src/main/resources/LoggingMessages.properties b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/LoggingMessages.properties new file mode 100644 index 0000000000..ada808be0e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/definitions.xml b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/definitions.xml new file mode 100644 index 0000000000..0a39912bf0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/definitions.xml @@ -0,0 +1,46 @@ + + + + + + + FINE + LoggingMessages.properties + + + + + + + INFO + LoggingMessages.properties + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..be63597c12 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Payment.composite b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Payment.composite new file mode 100644 index 0000000000..df54d0c1c2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/policies/src/main/resources/Payment.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java b/branches/sca-java-2.0-M4/itest/policies/src/test/java/org/apache/tuscany/sca/itest/policies/PaymentTestCase.java new file mode 100644 index 0000000000..3385ee9071 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/pom.xml b/branches/sca-java-2.0-M4/itest/pom.xml new file mode 100644 index 0000000000..b8ec15dea7 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/pom.xml @@ -0,0 +1,167 @@ + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-itest + pom + Apache Tuscany SCA Integration Tests + + + + junit + junit + 4.5 + compile + + + + + + default + + true + + + builder + bpel + callback-api + callback-basic + callback-basic-ws + callback-complex-type + callback-multiple-wires + callback-separatethread + component-type + contribution-folder + contribution-zip + + distribution + exceptions + implementation-spring + interfaces + jms + nodes + + + recursive-multi-level + references + scaclient-api + scopes + scdl + services + service-reference + wires + policies + + + + + old + + bpel + builder + callablereferences + callablereferences-ws + callback-api + callback-basic + callback-complex-type + callback-id + callback-multiple-wires + callback-separatethread + callback-set-callback + callback-set-conversation + component-type + contribution + + contribution-import-export + conversations + conversations-ws + corba + databindings + exceptions + exceptions-cross-binding + exceptions-cross-binding-ws + exceptions-simple-ws + extended-api + interfaces + + jms + jms-args + jms-callbacks + jms-definitions + jms-format + jms-selectors + large-sdo-ws + late-reference-resolution + oneway + operation-overloading + + policy + policy-security + policy-security-basicauth + policy-security-jsr250 + policy-security-token + + properties + recursive + recursive-multi-level + recursive-ws + references + scopes + serialization + services + spring + transaction + validation + wires + wsdl + wsdl2java + wsdlless + wsdl-multiple + ws-void-args-return + + + + + + jaxws + + diff --git a/branches/sca-java-2.0-M4/itest/properties/pom.xml b/branches/sca-java-2.0-M4/itest/properties/pom.xml new file mode 100644 index 0000000000..126d45a6fe --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/pom.xml @@ -0,0 +1,74 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-properties + Apache Tuscany SCA iTest Properties + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + + xalan + xalan + 2.7.1 + test + + + + org.apache.tuscany.sca + tuscany-core-databinding + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-databinding-jaxb + 2.0-M4-SNAPSHOT + compile + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyService.java new file mode 100644 index 0000000000..b0fd64c9da --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyServiceImpl.java new file mode 100644 index 0000000000..7b44ef02e4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/mysca/test/myservice/impl/MyTotalServiceImpl.java new file mode 100644 index 0000000000..e8c4341cf2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponent.java new file mode 100644 index 0000000000..68ce5a3cb6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABCDComponentImpl.java new file mode 100644 index 0000000000..c8d0d4cae4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponent.java new file mode 100644 index 0000000000..b727935bc1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getManyStringValues(); + + /** + * This is a method to get collection of property value from the SCA runtime environment. It is implemented in the + * class ABComponentImpl + */ + Collection getManyIntegers(); +} diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ABComponentImpl.java new file mode 100644 index 0000000000..e402131ce2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 manyStringValues; + private Collection 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 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 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 getManyStringValues() { + return manyStringValues; + } + + public Collection getManyIntegers() { + return manyIntegerValues; + } +} diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponent.java new file mode 100644 index 0000000000..52f9871d1b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/CDComponentImpl.java new file mode 100644 index 0000000000..fceda9d9ae --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 getManyValuesFileProperty() { + return this.manyValuesFileProperty; + } +} diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/ComplexPropertyBean.java new file mode 100644 index 0000000000..1642ab55f5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideService.java new file mode 100644 index 0000000000..acd1f26670 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/OverrideServiceImpl.java new file mode 100644 index 0000000000..71dce41efc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponent.java new file mode 100644 index 0000000000..9c7e8c3447 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyComponentImpl.java new file mode 100644 index 0000000000..64ca749e9f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/PropertyService.java new file mode 100644 index 0000000000..a57ccd90c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Bar.java new file mode 100644 index 0000000000..c147a2affe --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo1.java new file mode 100644 index 0000000000..7c700903d6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo2.java new file mode 100644 index 0000000000..1d2e563095 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/org/apache/tuscany/sca/itest/cdi/Foo3.java new file mode 100644 index 0000000000..54082e297a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ObjectFactory.java new file mode 100644 index 0000000000..15fb49ea4e --- /dev/null +++ b/branches/sca-java-2.0-M4/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 http://java.sun.com/xml/jaxb +// 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. + *

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 createMyRCProps(ReturnCodeProperties value) { + return new JAXBElement(_MyRCProps_QNAME, ReturnCodeProperties.class, null, value); + } + +} diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/ReturnCodeProperties.java new file mode 100644 index 0000000000..0a1d4a34a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 http://java.sun.com/xml/jaxb +// 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; + +/** + *

Java class for ReturnCodeProperties complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+ * <complexType name="ReturnCodeProperties">
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="AInt" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ *         <element name="BInteger" type="{http://www.w3.org/2001/XMLSchema}integer"/>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@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/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/package-info.java b/branches/sca-java-2.0-M4/itest/properties/src/main/java/test/jaxb/props/package-info.java new file mode 100644 index 0000000000..6a6fdd00cc --- /dev/null +++ b/branches/sca-java-2.0-M4/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 http://java.sun.com/xml/jaxb +// 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/branches/sca-java-2.0-M4/itest/properties/src/main/resources/ConstructorPropertyInjection.composite b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/ConstructorPropertyInjection.composite new file mode 100644 index 0000000000..af65f887c0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/ConstructorPropertyInjection.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + fubar + + + + + + fubar + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/Outer.composite b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/Outer.composite new file mode 100644 index 0000000000..5e767b1e0e --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/Outer.composite @@ -0,0 +1,43 @@ + + + + + Raleigh + 2008 + + + + + + + + + + + + + + + Durham + 2009 + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/OuterPropertyTest.composite b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/OuterPropertyTest.composite new file mode 100644 index 0000000000..95ee1157bf --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/OuterPropertyTest.composite @@ -0,0 +1,42 @@ + + + + + + + 125 + + + Overriden A + Overriden B + Overriden C + Overriden D + + Overriden Y + Overriden Z + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/PropertyTest.composite b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/PropertyTest.composite new file mode 100644 index 0000000000..36f75d52a1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/PropertyTest.composite @@ -0,0 +1,260 @@ + + + + + + + + + 1 + + + a + b + c + d + + y + z + + + + + + + + 1 + 11 + 111 + + + 2 + 22 + 222 + + TestString_1 + TestString_2 + 10 + 20 + 27 + 79.34 + 184.52 + 50.05 + 25.52 + + 54 + 158.68 + 369.04 + + + + + + + TestString_3 + TestString_4 + 100 + 200 + + + + + + + + + + + + + + f + + + + Apache + Tuscany + Java SCA + + + 123 + 456 + 789 + + + + + + + + + aValue + + + + 25 + + + + + + + + TestString_1 + TestString_2 + 10 + 27 + 79.34 + 25.52 + 184.52 + 50.05 + 20 + + 1 + 11 + 111 + + + 2 + 22 + 222 + + + 54 + 158.68 + 369.04 + + + + + + TestElementString_1 + TestElementString_2 + 10 + 27 + 79.34 + 25.52 + 184.52 + 50.05 + 20 + + 1 + 11 + 111 + + + 2 + 22 + 222 + + + 54 + 158.68 + 369.04 + + + + + + 1 + 11.11 + 111.111 + + 11 + 1111.1111 + 11111.11111 + + + + 2 + 22.22 + 222.222 + + 22 + 2222.2222 + 22222.22222 + + + + 3 + 33.33 + 333.333 + + 33 + 3333.3333 + 33333.33333 + + + + + RTP + 2006 + + Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday + + + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + + + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0 + + + + + 10 + 10 + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/customer.xsd b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/customer.xsd new file mode 100644 index 0000000000..7421750f1b --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/customer.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/fileProperty.txt b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/fileProperty.txt new file mode 100644 index 0000000000..0d3d9ead83 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/fileProperty.txt @@ -0,0 +1,21 @@ + + + +fileValue diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/manyValuesFileProperty.txt b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/manyValuesFileProperty.txt new file mode 100644 index 0000000000..6d4180ee2f --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/manyValuesFileProperty.txt @@ -0,0 +1,23 @@ + + +fileValueOne +fileValueTwo +fileValueThree +fileValueFour diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/mySimpleService.composite b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/mySimpleService.composite new file mode 100644 index 0000000000..3cf25384e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/mySimpleService.composite @@ -0,0 +1,40 @@ + + + + + + + + + + Raleigh + 2008 + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcProps.txt b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcProps.txt new file mode 100644 index 0000000000..052c291fd0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcProps.txt @@ -0,0 +1,22 @@ + + + + 20 + 20 + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcprops.xsd b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcprops.xsd new file mode 100644 index 0000000000..21289fa7b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/properties/src/main/resources/rcprops.xsd @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java b/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/MyTotalServiceTestCase.java new file mode 100644 index 0000000000..efc635c72b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java b/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/OuterPropertyTestCase.java new file mode 100644 index 0000000000..0906a45ab3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 iterator = outerABService.getManyIntegers().iterator(); + assertEquals(123, iterator.next().intValue()); + assertEquals(456, iterator.next().intValue()); + assertEquals(789, iterator.next().intValue()); + } +} diff --git a/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java b/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/PropertyTestCase.java new file mode 100644 index 0000000000..eb217600db --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 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/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java b/branches/sca-java-2.0-M4/itest/properties/src/test/java/org/apache/tuscany/sca/itest/cdi/ConstructorPropertyInjectionTestCase.java new file mode 100644 index 0000000000..a0213ced46 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/recursive-multi-level/pom.xml b/branches/sca-java-2.0-M4/itest/recursive-multi-level/pom.xml new file mode 100644 index 0000000000..c82860fb74 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/recursive-multi-level/pom.xml @@ -0,0 +1,61 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + + + itest-recursive-multi-level + Apache Tuscany SCA iTest Recusive Multi-Level + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + + xalan + xalan + 2.7.1 + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyService.java new file mode 100644 index 0000000000..986c8305dd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MyServiceImpl.java new file mode 100644 index 0000000000..6cad998042 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalService.java new file mode 100644 index 0000000000..261eff2584 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/java/mysca/test/myservice/MySimpleTotalServiceImpl.java new file mode 100644 index 0000000000..f3c9280f96 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite new file mode 100644 index 0000000000..090bc49a41 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService1Auto.composite @@ -0,0 +1,52 @@ + + + + + Level 1 + 2001 + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite new file mode 100644 index 0000000000..8c1a9a2f72 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService2Auto.composite @@ -0,0 +1,49 @@ + + + + + Level 2 + 2002 + + + + Default 2 + 1992 + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite new file mode 100644 index 0000000000..884a8b0a96 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/main/resources/TotalService3Auto.composite @@ -0,0 +1,52 @@ + + + + + Level 3 + 2003 + + + + Default 3 + 1993 + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java b/branches/sca-java-2.0-M4/itest/recursive-multi-level/src/test/java/test/sca/tests/MultiLevelTestCase.java new file mode 100644 index 0000000000..b9b4e3ba7c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/pom.xml b/branches/sca-java-2.0-M4/itest/references/pom.xml new file mode 100644 index 0000000000..1c543e50ba --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/references/pom.xml @@ -0,0 +1,52 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-references + Apache Tuscany SCA iTest References + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + diff --git a/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponent.java new file mode 100644 index 0000000000..f8c0850118 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/AComponentImpl.java new file mode 100644 index 0000000000..cd0aad3eea --- /dev/null +++ b/branches/sca-java-2.0-M4/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 dReferences; + + @Reference(name = "dReferenceArray") + public DComponent[] dReferenceArray; + + @Reference(name = "dServiceReferences") + public List> 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 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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponent.java new file mode 100644 index 0000000000..785920bb2d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentImpl.java new file mode 100644 index 0000000000..211e6160f6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/BComponentWrongTargetImpl.java new file mode 100644 index 0000000000..47a1f9bde8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponent.java new file mode 100644 index 0000000000..d436c28adc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/CComponentImpl.java new file mode 100644 index 0000000000..a1823e1cdc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponent.java new file mode 100644 index 0000000000..80617bdec2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java b/branches/sca-java-2.0-M4/itest/references/src/main/java/org/apache/tuscany/sca/itest/references/DComponentImpl.java new file mode 100644 index 0000000000..d181ac96ca --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/main/resources/AutoWiredReferencesTest.composite b/branches/sca-java-2.0-M4/itest/references/src/main/resources/AutoWiredReferencesTest.composite new file mode 100644 index 0000000000..3934025e64 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/references/src/main/resources/AutoWiredReferencesTest.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/references/src/main/resources/InnerReferencesTest.composite b/branches/sca-java-2.0-M4/itest/references/src/main/resources/InnerReferencesTest.composite new file mode 100644 index 0000000000..871a846edf --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/references/src/main/resources/InnerReferencesTest.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/references/src/main/resources/ManualWiredReferencesTest.composite b/branches/sca-java-2.0-M4/itest/references/src/main/resources/ManualWiredReferencesTest.composite new file mode 100644 index 0000000000..52d6fe48c1 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/references/src/main/resources/ManualWiredReferencesTest.composite @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/AutoWiredReferenceTestCase.java new file mode 100644 index 0000000000..76264d308f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/InnerReferenceTestCase.java new file mode 100644 index 0000000000..6e4212fd9a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/references/src/test/java/org/apache/tuscany/sca/itest/references/ManualWiredReferenceTestCase.java new file mode 100644 index 0000000000..2fce95401e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scaclient-api/pom.xml b/branches/sca-java-2.0-M4/itest/scaclient-api/pom.xml new file mode 100644 index 0000000000..de34473c63 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scaclient-api/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-scaclient-api + Apache Tuscany SCA iTest SCAClient API + + + + org.apache.tuscany.sca + tuscany-sca-client-impl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + runtime + + + + diff --git a/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldService.java b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldService.java new file mode 100644 index 0000000000..1c7edaefb6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/java/itest/HelloworldServiceImpl.java new file mode 100644 index 0000000000..4b9910bb21 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/Helloworld.composite b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/Helloworld.composite new file mode 100644 index 0000000000..3f0e0a164c --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/Helloworld.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d8604a5cc0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scaclient-api/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java b/branches/sca-java-2.0-M4/itest/scaclient-api/src/test/java/test/scaclient/SCAClientTestCase.java new file mode 100644 index 0000000000..a331e4dd22 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scdl/pom.xml b/branches/sca-java-2.0-M4/itest/scdl/pom.xml new file mode 100644 index 0000000000..d0ccbfb131 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scdl/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + + itest-scdl + Apache Tuscany SCA iTest SCDL + + + + org.apache.tuscany.sca + tuscany-deployment + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-jsonp + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-rmi + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-jms + 2.0-M4-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + compile + + copy-dependencies + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java b/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ContributionTestCase.java new file mode 100644 index 0000000000..c56545dd3b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java b/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/SCDLTestCase.java new file mode 100644 index 0000000000..18fb9394bf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java b/branches/sca-java-2.0-M4/itest/scdl/src/test/java/org/apache/tuscany/sca/itest/scdl/ValidateDependenciesTestCase.java new file mode 100644 index 0000000000..44695e5dde --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scdl/src/test/resources/test.composite b/branches/sca-java-2.0-M4/itest/scdl/src/test/resources/test.composite new file mode 100644 index 0000000000..aa11c0d092 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scdl/src/test/resources/test.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/scopes/pom.xml b/branches/sca-java-2.0-M4/itest/scopes/pom.xml new file mode 100644 index 0000000000..7d8f94d4ea --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scopes/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + Apache Tuscany SCA iTest Scopes + itest-scopes + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + + diff --git a/branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java b/branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/CompositeScopeStateVerifierImpl.java new file mode 100644 index 0000000000..208ac3ba44 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 moduleState; + + public CompositeScopeStateVerifierImpl() { + moduleState = new ThreadLocal(); + } + + public void setState(int i) { + moduleState.set(i); + } + + public boolean checkState(int i) { + return (moduleState.get() == i); + } + +} diff --git a/branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java b/branches/sca-java-2.0-M4/itest/scopes/src/main/java/org/apache/tuscany/sca/itest/scopes/StateVerifier.java new file mode 100644 index 0000000000..e6bf08ccf2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/scopes/src/main/resources/scopes.composite b/branches/sca-java-2.0-M4/itest/scopes/src/main/resources/scopes.composite new file mode 100644 index 0000000000..83a71218f5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/scopes/src/main/resources/scopes.composite @@ -0,0 +1,29 @@ + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java b/branches/sca-java-2.0-M4/itest/scopes/src/test/java/org/apache/tuscany/sca/test/ScopeTestCase.java new file mode 100644 index 0000000000..594bdd5038 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/pom.xml b/branches/sca-java-2.0-M4/itest/service-reference/pom.xml new file mode 100644 index 0000000000..9d3afa4840 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/service-reference/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-service-reference + Apache Tuscany SCA iTest ServiceReference + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponent.java new file mode 100644 index 0000000000..8b5cf4d29a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/AComponentImpl.java new file mode 100644 index 0000000000..3f68ac828a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 cReference = componentContext.getServiceReference(CComponent.class, "cReference"); + return b.fooC(cReference); + } + + public String fooD() { + ServiceReference 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 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/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponent.java new file mode 100644 index 0000000000..18242cd594 --- /dev/null +++ b/branches/sca-java-2.0-M4/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); +} diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/BComponentImpl.java new file mode 100644 index 0000000000..dd143df036 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 cReference) { + return "B" + cReference.getService().foo(); + } + +} diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/Base64Binary.java new file mode 100644 index 0000000000..fb436ae10c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponent.java new file mode 100644 index 0000000000..fc15b632d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/CComponentImpl.java new file mode 100644 index 0000000000..276093b69f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponent.java new file mode 100644 index 0000000000..84e15b5eb2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 aReference); + + String fooString(String aReferenceString); +} diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java b/branches/sca-java-2.0-M4/itest/service-reference/src/main/java/org/apache/tuscany/sca/itest/serviceref/DComponentImpl.java new file mode 100644 index 0000000000..db99472385 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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) obj; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Invoking service: " + requestContext.getServiceName()); + return "D" + aReference.getService().foo(); + } + + public String fooString(String aReferenceString) { + ServiceReference aReference = null; + try { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64Binary.decode(aReferenceString))); + Object obj = ois.readObject(); + aReference = (ServiceReference) obj; + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println("Invoking service: " + requestContext.getServiceName()); + return "D" + aReference.getService().foo(); + } +} diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeA/CompositeA.composite b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeA/CompositeA.composite new file mode 100644 index 0000000000..fb88cd8bea --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeA/CompositeA.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeB/CompositeB.composite b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeB/CompositeB.composite new file mode 100644 index 0000000000..06e4c63e94 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/nodeB/CompositeB.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite new file mode 100644 index 0000000000..63302847b5 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/service-reference/src/main/resources/servicereference/ServiceReferenceTest.composite @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java b/branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/CallableReferenceRemoteTestCase.java new file mode 100644 index 0000000000..843afe207c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java b/branches/sca-java-2.0-M4/itest/service-reference/src/test/java/org/apache/tuscany/sca/itest/serviceref/ServiceReferenceTestCase.java new file mode 100644 index 0000000000..1a454c939a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/pom.xml b/branches/sca-java-2.0-M4/itest/services/pom.xml new file mode 100644 index 0000000000..9c5f5416df --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/services/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-services + Apache Tuscany SCA iTest Services + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponent.java new file mode 100644 index 0000000000..26e58dc530 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/AComponentImpl.java new file mode 100644 index 0000000000..627ff4976f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponent.java new file mode 100644 index 0000000000..d04bd1b985 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/BComponentImpl.java new file mode 100644 index 0000000000..01df89a8fa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponent.java new file mode 100644 index 0000000000..07397e4502 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/CComponentImpl.java new file mode 100644 index 0000000000..8713e5ab22 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/D1Component.java new file mode 100644 index 0000000000..842a85e000 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponent.java new file mode 100644 index 0000000000..8a3923b351 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java b/branches/sca-java-2.0-M4/itest/services/src/main/java/org/apache/tuscany/sca/itest/services/DComponentImpl.java new file mode 100644 index 0000000000..e52692fbf4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/services/src/main/resources/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/itest/services/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e21261d8d0 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/services/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/services/src/main/resources/ServicesTest.composite b/branches/sca-java-2.0-M4/itest/services/src/main/resources/ServicesTest.composite new file mode 100644 index 0000000000..e7d56032ea --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/services/src/main/resources/ServicesTest.composite @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java b/branches/sca-java-2.0-M4/itest/services/src/test/java/org/apache/tuscany/sca/itest/services/ServicesTestCase.java new file mode 100644 index 0000000000..da779b2c54 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/wires/pom.xml b/branches/sca-java-2.0-M4/itest/wires/pom.xml new file mode 100644 index 0000000000..5ad88d2e84 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/wires/pom.xml @@ -0,0 +1,53 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-itest + 2.0-M4-SNAPSHOT + ../pom.xml + + itest-wires + Apache Tuscany SCA iTest Wires Basic + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java b/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClient.java new file mode 100644 index 0000000000..f5a4337254 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java b/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireClientImpl.java new file mode 100644 index 0000000000..82f0e26d58 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java b/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireService.java new file mode 100644 index 0000000000..67df1e3a52 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java b/branches/sca-java-2.0-M4/itest/wires/src/main/java/org/apache/tuscany/sca/itest/WireServiceImpl.java new file mode 100644 index 0000000000..f0308252ba --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/itest/wires/src/main/resources/WireTest.composite b/branches/sca-java-2.0-M4/itest/wires/src/main/resources/WireTest.composite new file mode 100644 index 0000000000..614beaec00 --- /dev/null +++ b/branches/sca-java-2.0-M4/itest/wires/src/main/resources/WireTest.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java b/branches/sca-java-2.0-M4/itest/wires/src/test/java/org/apache/tuscany/sca/itest/WireTestCase.java new file mode 100644 index 0000000000..2a0095cabc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/LICENSE b/branches/sca-java-2.0-M4/modules/assembly-xml/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/assembly-xml/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..210611129b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/NOTICE b/branches/sca-java-2.0-M4/modules/assembly-xml/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/pom.xml b/branches/sca-java-2.0-M4/modules/assembly-xml/pom.xml new file mode 100644 index 0000000000..f739830e25 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-assembly-xml + Apache Tuscany SCA Assembly XML Model + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + + + org.apache.geronimo.specs + geronimo-stax-api_1.0_spec + 1.0.1 + compile + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + runtime + + + stax + stax-api + + + + + + org.apache.tuscany.sca + tuscany-assembly-xsd + 2.0-M4-SNAPSHOT + runtime + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java new file mode 100644 index 0000000000..da8c64b426 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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)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)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 targets = new ArrayList(); + 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 void resolveContracts(List 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 void resolveContracts(Base parent, List 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 void resolveAbstractContracts(List 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 elements under the + 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 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 + 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 + 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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeDocumentProcessor.java new file mode 100644 index 0000000000..b5fe005812 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return ComponentType.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeModelResolver.java new file mode 100644 index 0000000000..9a4a0dc035 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 map = new HashMap(); + + 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 resolveModel(Class 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java new file mode 100644 index 0000000000..a878054d99 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + /** + * 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 = assemblyFactory.createComponentType(); + + } else if (Constants.SERVICE_QNAME.equals(name)) { + + // Read a + 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 = 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 = 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 element + policyProcessor.readPolicies(componentType, reader); + + } else if (Constants.CALLBACK_QNAME.equals(name)) { + + // Read a + callback = assemblyFactory.createCallback(); + contract.setCallback(callback); + policyProcessor.readPolicies(callback, reader); + + } else if (OPERATION_QNAME.equals(name)) { + + // Read an + 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) { + + // and + contract.setInterfaceContract((InterfaceContract)extension); + + } else if (extension instanceof Binding) { + + // and + 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 element + writeStartDocument(writer, COMPONENT_TYPE); + + // Write 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 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 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 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 getModelType() { + return ComponentType.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeDocumentProcessor.java new file mode 100644 index 0000000000..f3f25f0b65 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Composite.class; + } + +} // end class diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeModelResolver.java new file mode 100644 index 0000000000..9b02df8b7a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 map = new HashMap(); + + 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 resolveModel(Class 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java new file mode 100644 index 0000000000..026e0426af --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + private XPathHelper xpathHelper; + private PolicyFactory intentAttachPointTypeFactory; + private StAXAttributeProcessor 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 = 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 = 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 + 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 + 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 + 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 + 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 + componentProperty = assemblyFactory.createComponentProperty(); + property = componentProperty; + String source = getString(reader, SOURCE); + if (source != null) { + source = source.trim(); + } + componentProperty.setSource(source); + if (source != null) { + // $/... + 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 + 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 = 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 = 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 = 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) { + + // and + // + if (contract != null) { + contract.setInterfaceContract((InterfaceContract)extension); + } else { + if (name.getNamespaceURI().equals(SCA11_NS)) { + error(monitor, "UnexpectedInterfaceElement", extension); + //throw new ContributionReadException("Unexpected element found. It should appear inside a or 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); + } + // and + // + 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 element found. It should appear inside a or 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); + } + // + if (component != null) { + component.setImplementation((Implementation)extension); + } else { + if (name.getNamespaceURI().equals(SCA11_NS)) { + error(monitor, "UnexpectedImplementationElement", extension); + //throw new ContributionReadException("Unexpected element found. It should appear inside a 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 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 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 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 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 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 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 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 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 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 elements + for (Reference reference : composite.getReferences()) { + CompositeReference compositeReference = (CompositeReference)reference; + + // Write list of promoted references + List promote = new ArrayList(); + for (ComponentReference promoted : compositeReference.getPromotedReferences()) { + promote.add(promoted.getName()); + } + + // Write 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 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 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 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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConfiguredOperationProcessor.java new file mode 100644 index 0000000000..bcba763c1c --- /dev/null +++ b/branches/sca-java-2.0-M4/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, 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 + 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 + 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 getModelType() { + return ConfiguredOperation.class; + } + +} + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Constants.java new file mode 100644 index 0000000000..ad1e7cd83f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/DefaultBeanModelProcessor.java new file mode 100644 index 0000000000..198ddfbfeb --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extends BaseAssemblyProcessor implements StAXArtifactProcessor { + + private QName artifactType; + private Class modelClass; + private Object modelFactory; + private Method factoryMethod; + private Map setterMethods = new HashMap(); + private Map getterMethods = new HashMap(); + + public DefaultBeanModelProcessor(FactoryExtensionPoint modeFactories, + QName artifactType, + Class 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 attrs = new ArrayList(); + for (Map.Entry 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 getModelType() { + return modelClass; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java new file mode 100644 index 0000000000..4b9f07ae7e --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Endpoint.class; + } + + public void resolve(Endpoint model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointReferenceProcessor.java new file mode 100644 index 0000000000..dd1b6f5d62 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return EndpointReference.class; + } + + public void resolve(EndpointReference model, ModelResolver resolver, ProcessorContext context) throws ContributionResolveException { + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/Messages.java new file mode 100644 index 0000000000..320c4eae62 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java new file mode 100644 index 0000000000..b47be74712 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 attrs =new ArrayList(); + 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 qnames = new ArrayList(); + 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 qnames = new ArrayList(); + 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 requiredIntents = new ArrayList(); + 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 resolvedPolicySets = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java new file mode 100644 index 0000000000..8ac0de9617 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 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 + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefaultDefinitionsExtensionPoint.java new file mode 100644 index 0000000000..1f256de3a2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 documents = new HashSet(); + private List definitions = new ArrayList(); + 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 definitionsDeclarations; + try { + definitionsDeclarations = ServiceDiscovery.getInstance().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 getDefinitions() { + if (!loaded) { + loadDefinitionsDocuments(); + URLArtifactProcessorExtensionPoint processors = + registry.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); + URLArtifactProcessor 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsDocumentProcessor.java new file mode 100644 index 0000000000..d0a42be34e --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + private StAXArtifactProcessor extensionProcessor; + private XMLInputFactory inputFactory; + private DefinitionsFactory definitionsFactory; + + + + /** + * Constructs a new SCADefinitions processor. + * + * @param modelFactories + * @param staxProcessor + */ + public DefinitionsDocumentProcessor(FactoryExtensionPoint modelFactories, + StAXArtifactProcessor staxProcessor) { + this.extensionProcessor = (StAXArtifactProcessor)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() { + 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 getModelType() { + return Definitions.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsExtensionPoint.java new file mode 100644 index 0000000000..3058b1f5b6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getDefinitions(); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/DefinitionsProcessor.java new file mode 100644 index 0000000000..b545e62469 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + private StAXArtifactProcessor 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 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 intents = new ArrayList(); + List policySets = new ArrayList(); + List referredPolicySets = new ArrayList(); + + 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 getModelType() { + return Definitions.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/definitions/xml/Messages.java new file mode 100644 index 0000000000..38cc4a9de2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/BindingTypeProcessor.java new file mode 100644 index 0000000000..70c71c5f1f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensionProcessor) { + super(policyFactory, extensionProcessor); + } + + public BindingTypeProcessor(FactoryExtensionPoint modelFactories, + StAXArtifactProcessor 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ExtensionTypeProcessor.java new file mode 100644 index 0000000000..95d8e67bf7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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, PolicyConstants { + + private PolicyFactory policyFactory; + + + protected abstract ExtensionType resolveExtensionType(ExtensionType extnType, ModelResolver resolver, ProcessorContext context) + throws ContributionResolveException; + + public ExtensionTypeProcessor(PolicyFactory policyFactory, + StAXArtifactProcessor 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 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 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 + 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 alwaysProvided = new ArrayList(); + 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 mayProvide = new ArrayList(); + 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 getModelType() { + return ExtensionType.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/ImplementationTypeProcessor.java new file mode 100644 index 0000000000..ec4e17385f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensionProcessor) { + super(policyFactory, extensionProcessor); + } + + public ImplementationTypeProcessor(FactoryExtensionPoint modelFactories, + StAXArtifactProcessor 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/IntentProcessor.java new file mode 100644 index 0000000000..ac4f81d5a9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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, + 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 + 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 resolvedTypes = new HashSet(); + 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 requiredIntents = new ArrayList(); + 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 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 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 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 excludedIntents = new ArrayList(); + 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 getModelType() { + return Intent.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/Messages.java new file mode 100644 index 0000000000..ee8b5274cc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyConstants.java new file mode 100644 index 0000000000..979dad3c8b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java new file mode 100644 index 0000000000..e647d1e575 --- /dev/null +++ b/branches/sca-java-2.0-M4/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, + PolicyConstants { + + private PolicyFactory policyFactory; + private StAXArtifactProcessor extensionProcessor; + private XPathHelper xpathHelper; + // private XPathFactory xpathFactory; + + + public PolicySetProcessor(ExtensionPointRegistry registry, + StAXArtifactProcessor 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 + 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 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 getModelType() { + return PolicySet.class; + } + + private void resolveProvidedIntents(PolicySet policySet, ModelResolver resolver, ProcessorContext context) + throws ContributionResolveException { + if (policySet != null) { + //resolve all provided intents + List providedIntents = new ArrayList(); + 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 referredPolicySets = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunction.java new file mode 100644 index 0000000000..10f142c67b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 functions = + new HashSet(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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolver.java new file mode 100644 index 0000000000..ca44667903 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 + *
    + *
  • InterfaceRef( InterfaceName ) + *
  • OperationRef( InterfaceName/OperationName ) + *
  • MessageRef( InterfaceName/OperationName/MessageName ) + *
+ * + * Intent Related Functions + *
    + *
  • IntentRefs( IntentList ) + *
+ * + * URI Based Function + *
    + *
  • URIRef( URI ) + *
+ */ +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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/sca-policy-1.1-intents-definitions-cd03.xml @@ -0,0 +1,242 @@ + + + + + + + + Communication through the binding requires that the + server is authenticated by the client + + + + + + + + Communication through the binding requires that the + client is authenticated by the server + + + + + + + + A convenience intent to help migration + + + + + + Communication through the binding requires that the + client and server to authenticate each other + + + + + + Communication through the binding prevents unauthorized + users from reading the messages + + + + + + + + Communication through the binding prevents tampering + with the messages sent between the client and the service. + + + + + + + + Ensures clients are authorized to use services. + + + + + + + + + This intent is used to indicate that a message sent + by a client is always delivered to the component. + + + + + + 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. + + + + + + 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. + + + + + + This intent is used to indicate that all the messages are + delivered to the component in the order they were sent by + the client. + + + + + + + A managed transaction environment is necessary in order to + run the component. The specific type of managed transaction + needed is not constrained. + + + + 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. + + + + + A component marked with managedTransaction.local needs to + run within a local transaction containment (LTC) that + is started and ended by the SCA runtime. + + + + + + + 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. + + + + + + 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. + + + + + + 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. + + + + + + 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. + + + + + + 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. + + + + + + Used to indicate that the component requires both the + managedTransaction.global and the propagatesTransactions + intents + + + + + + + Indicates that request/response operations for the + interface of this wire are "long running" and must be + treated as two separate message transmissions + + + + + + Specifies that the SOAP messaging model is used for delivering + messages. + + + + + + + + Requires that the messages are delivered and received via the + JMS API. + + + + + + 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. + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..5330206cd0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/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.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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor new file mode 100644 index 0000000000..358969d621 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.resolver.ModelResolver new file mode 100644 index 0000000000..00862d32de --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/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.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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..33129c8baa --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint b/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.DefinitionsExtensionPoint new file mode 100644 index 0000000000..22c2a0549c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/assembly/xml/assembly-xml-validation-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 element found. It should appear inside a or element. +UnexpectedBindingElement = Unexpected element found. It should appear inside a or element. +UnexpectedImplementationElement = Unexpected element found. It should appear inside a 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/definitions/xml/definitions-xml-validation-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/MultiplicityReadWriteTestCase.java new file mode 100644 index 0000000000..0d5e69bd61 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadAllTestCase.java new file mode 100644 index 0000000000..155c0c5a47 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadDocumentTestCase.java new file mode 100644 index 0000000000..a886908589 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 documentProcessor; + private static ModelResolver resolver; + private static XMLInputFactory inputFactory; + private static StAXArtifactProcessor 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 { + + ValidationSchemaExtensionPoint schemas = new DefaultValidationSchemaExtensionPoint(); + schemas.addSchema(getClass().getClassLoader().getResource(TUSCANY_11_XSD).toString()); + XMLInputFactory validatingInputFactory = new DefaultValidatingXMLInputFactory(inputFactory, schemas); + DefaultFactoryExtensionPoint factories = new DefaultFactoryExtensionPoint(new DefaultExtensionPointRegistry()); + 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(); + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadTestCase.java new file mode 100644 index 0000000000..05d320b211 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyAttributeTestCase.java new file mode 100644 index 0000000000..9646356eb7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = ""+ + ""+ + ""+ + ""+ + ""+ + ""; + + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteAnyElementTestCase.java new file mode 100644 index 0000000000..42730415b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + private static final String XML_UNKNOWN_IMPL = + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + private static final String XML_UNKNOWN_IMPL_WITH_INVALID_ATTRIBUTE = + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ReadWriteLocalCompositeTestCase.java new file mode 100644 index 0000000000..7787361e62 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = ""+ + ""+ + ""; + + @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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolvePolicyTestCase.java new file mode 100644 index 0000000000..df588e3504 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 documentProcessor; + private static ModelResolver resolver; + private static URLArtifactProcessor 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/ResolveTestCase.java new file mode 100644 index 0000000000..28e679da4a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestAttributeProcessor.java new file mode 100644 index 0000000000..b6f4c11ac2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return String.class; + } + + public void resolve(String arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestPolicyProcessor.java new file mode 100644 index 0000000000..cfec8dee7a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return PolicyExpression.class; + } + + public void resolve(PolicyExpression arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + } + + public class MockPolicyImplOne implements PolicyExpression { + public T getPolicy() { + return null; + } + + public void setName(QName name) { + } + + public 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingFactoryImpl.java new file mode 100644 index 0000000000..cbfec53f65 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java new file mode 100644 index 0000000000..2f13eb8b6d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensions = new ArrayList(); + + private Component targetComponent; + private ComponentService targetComponentService; + private Binding targetBinding; + + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + 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 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 getPolicySets() { + // TODO Auto-generated method stub + return policySets; + } + + public List 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 getAlwaysProvidedIntents() { + return Collections.emptyList(); + } + + public List getMayProvidedIntents() { + return Collections.emptyList(); + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WireTestCase.java new file mode 100644 index 0000000000..543aaf9893 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 staxProcessor; + private static ModelResolver resolver; + private static URLArtifactProcessor 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java new file mode 100644 index 0000000000..a19ce79490 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteNamespacesTestCase.java new file mode 100644 index 0000000000..f50cd5811f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java new file mode 100644 index 0000000000..58e6e534b9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java new file mode 100644 index 0000000000..b1720ea8e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policyDefinitionsProcessor = null; + private static Definitions definitions; + private static Map intentTable = new Hashtable(); + private static Map policySetTable = new Hashtable(); + private static Map bindingTypesTable = new Hashtable(); + private static Map implTypesTable = new Hashtable(); + 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java new file mode 100644 index 0000000000..a148e33029 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return MockPolicy.class; + } + + public void resolve(MockPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/PolicyXPathFunctionResolverTestCase.java new file mode 100644 index 0000000000..f0bd5d8bde --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/ReadDocumentTestCase.java new file mode 100644 index 0000000000..c39dede56d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 staxProcessor; + private ProcessorContext context; + + private static final QName elementToProcess = + new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "implementationType"); + + private Map intentTable = new Hashtable(); + private Map policySetTable = new Hashtable(); + private Map bindingTypesTable = new Hashtable(); + private Map implTypesTable = new Hashtable(); + 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 intents = new ArrayList(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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/policy/xml/TestPolicyProcessor.java new file mode 100644 index 0000000000..aea2c3adb8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + 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 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 getPolicy() { + return null; + } + + public void setName(QName name) { + } + + public 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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite new file mode 100644 index 0000000000..961a40b841 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType new file mode 100644 index 0000000000..2f4518a42c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite new file mode 100644 index 0000000000..0d73d1a189 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Multiplicity.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite new file mode 100644 index 0000000000..bf3676c585 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/NestedCalculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite new file mode 100644 index 0000000000..9f40faa806 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/RMIBindingTest.composite @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite new file mode 100644 index 0000000000..807e256fc5 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AValue + InterestingURI + + + BValue + BoringURI + + + + + 123 + + + 123 + 123 + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite new file mode 100644 index 0000000000..8ca71a0580 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllDivide.composite @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite new file mode 100644 index 0000000000..5c7e4435bb --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + AValue + InterestingURI + + + BValue + BoringURI + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/another_test_definitions.xml @@ -0,0 +1,96 @@ + + + + + + + + Sample Intent + + + + + + + Sample Intent + + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + + + + Sample Intent + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite new file mode 100644 index 0000000000..4949cd017f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/local.composite @@ -0,0 +1,27 @@ + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/test_definitions.xml @@ -0,0 +1,206 @@ + + + + + + + + + + + + Test Intent + + + + + + Protect messages from unauthorized reading or modification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + ... + + + + + + + + + + + sp:X509v3 + + + + + + + + + + + + + + + + + + Protect messages from unauthorized reading or modification + + + + + + Protect messages from unauthorized reading or modification + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + + + + + + Communitcation thro this binding must prevent + unauthorized modification of the messages. + + + + + + Communitcation thro this binding required + Authentication. + + + + + + All messages to and from this implementation must be logged + + + + + + Need to figure out some description for this + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + Test Intent + + + + + + Protect messages from unauthorized reading or modification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + ... + + + + + + + + + + + sp:X509v3 + + + + + + + + + + + + + + + + + + Protect messages from unauthorized reading or modification + + + + + + Protect messages from unauthorized reading or modification + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + + + + + + Communitcation thro this binding must prevent + unauthorized modification of the messages. + + + + + + Communitcation thro this binding required + Authentication. + + + + + + All messages to and from this implementation must be logged + + + + + + Need to figure out some description for this + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite new file mode 100644 index 0000000000..d6082a936d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml @@ -0,0 +1,204 @@ + + + + + + + + + + + + Test Intent + + + + + + Protect messages from unauthorized reading or modification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + ... + + + + + + + + + + + sp:X509v3 + + + + + + + + + + + + + + + + + + Protect messages from unauthorized reading or modification + + + + + + Protect messages from unauthorized reading or modification + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + + + + + + Communitcation thro this binding must prevent + unauthorized modification of the messages. + + + + + + Communitcation thro this binding required + Authentication. + + + + + + All messages to and from this implementation must be logged + + + + + + Need to figure out some description for this + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/LICENSE b/branches/sca-java-2.0-M4/modules/assembly-xsd/LICENSE new file mode 100644 index 0000000000..2ea1dcc129 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/assembly-xsd/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..05f5c8471e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/NOTICE b/branches/sca-java-2.0-M4/modules/assembly-xsd/NOTICE new file mode 100644 index 0000000000..78da9f5010 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/pom.xml b/branches/sca-java-2.0-M4/modules/assembly-xsd/pom.xml new file mode 100644 index 0000000000..398e055b93 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/pom.xml @@ -0,0 +1,31 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-assembly-xsd + Apache Tuscany SCA Assembly Model XSD Files + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/java/org/apache/tuscany/sca/assembly/xsd/Constants.java new file mode 100644 index 0000000000..b59cce55ab --- /dev/null +++ b/branches/sca-java-2.0-M4/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 CACHED_XSDS = XSDCache.cache(); + + static class XSDCache { + static Map cache() { + Map cachedXSDs = new HashMap(); + 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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..5007705d41 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd new file mode 100644 index 0000000000..e8e8f7625a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/XMLSchema.dtd @@ -0,0 +1,402 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +%xs-datatypes; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd new file mode 100644 index 0000000000..685e89a57e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/datatypes.dtd @@ -0,0 +1,204 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-secext-1.0.xsd @@ -0,0 +1,195 @@ + + + + + + + + + This type represents an element with arbitrary attributes. + + + + + + + + + + + This type is used for password elements per Section 4.1. + + + + + + + + + + This type is used for elements containing stringified binary data. + + + + + + + + + + This type represents a username token per Section 4.1 + + + + + + + + + + + A security token that is encoded in binary + + + + + + + + + + A security token key identifier + + + + + + + + + + Typedef to allow a list of usages (as URIs). + + + + + + This global attribute is used to indicate the usage of a referenced or indicated token within the containing context + + + + + This type represents a reference to an external security token. + + + + + + + + This type represents a reference to an embedded security token. + + + + + + + + + + This type is used reference a security token. + + + + + + + + + + + This complexType defines header block to use for security-relevant data directed at a specific SOAP actor. + + + + + The use of "any" is to allow extensibility and different forms of security data. + + + + + + + + This complexType defines a container for elements to be specified from any namespace as properties/parameters of a DSIG transformation. + + + + + The use of "any" is to allow extensibility from any namespace. + + + + + + + + This element defines the wsse:UsernameToken element per Section 4.1. + + + + + This element defines the wsse:BinarySecurityToken element per Section 4.2. + + + + + This element defines a security token reference + + + + + This element defines a security token embedded reference + + + + + This element defines a key identifier reference + + + + + This element defines the wsse:SecurityTokenReference per Section 4.3. + + + + + This element defines the wsse:Security SOAP header element per Section 4. + + + + + This element contains properties for transformations from any namespace, including DSIG. + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/oasis-200401-wss-wssecurity-utility-1.0.xsd @@ -0,0 +1,108 @@ + + + + + + + +This type defines the fault code value for Timestamp message expiration. + + + + + + + + + + +This global attribute supports annotating arbitrary elements with an ID. + + + + + + +Convenience attribute group used to simplify this schema. + + + + + + + + + +This type is for elements whose [children] is a psuedo-dateTime and can have arbitrary attributes. + + + + + + + + + + + +This type is for elements whose [children] is an anyURI and can have arbitrary attributes. + + + + + + + + + + + + +This complex type ties together the timestamp related elements into a composite type. + + + + + + + + + + + + + + +This element allows Timestamps to be applied anywhere element wildcards are present, +including as a SOAP header. + + + + + + + +This element allows an expiration time to be applied anywhere element wildcards are present. + + + + + + +This element allows a creation time to be applied anywhere element wildcards are present. + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-addr.xsd @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/ws-policy.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd new file mode 100644 index 0000000000..24e0b5a975 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/wsdli.xsd @@ -0,0 +1,35 @@ + + + + + + + + + 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 + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd new file mode 100644 index 0000000000..ac4b0ec8e6 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xml.xsd @@ -0,0 +1,117 @@ + + + + + + + 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 + + + + + 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: + <schema . . .> + . . . + <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. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + 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. + + + + + + In due course, we should install the relevant ISO 2- and 3-letter + codes as the enumerated possible values . . . + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/org/apache/tuscany/sca/assembly/xsd/xmldsig-core-schema.xsd @@ -0,0 +1,318 @@ + + + + + + ]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd new file mode 100644 index 0000000000..b5fc21e9c0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-1.1-cd04.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd new file mode 100644 index 0000000000..bcb9539c40 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ejb-1.1-cd01.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd new file mode 100644 index 0000000000..7f9baac45c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jca-1.1-cd04.xsd @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd new file mode 100644 index 0000000000..b7f58705cd --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-jms-1.1-cd04.xsd @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd new file mode 100644 index 0000000000..897e869806 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-sca-1.1-cd04.xsd @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd new file mode 100644 index 0000000000..24198c943d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-1.1-cd04.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd new file mode 100644 index 0000000000..4bc2e73d4c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-binding-ws-callback-1.1-cd04.xsd @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd new file mode 100644 index 0000000000..f13fbd1567 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-1.1-cd04.xsd @@ -0,0 +1,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd new file mode 100644 index 0000000000..7e2cd739fd --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-c-1.1-cd04.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd new file mode 100644 index 0000000000..b808125568 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-cpp-1.1-cd04.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd new file mode 100644 index 0000000000..1dcd515c98 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-contribution-java-1.1-cd02.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd new file mode 100644 index 0000000000..74cfe9a739 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-core-1.1-cd04.xsd @@ -0,0 +1,534 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd new file mode 100644 index 0000000000..2034e4d2c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-definitions-1.1-cd04.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd new file mode 100644 index 0000000000..11239e20d0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-bpel-1.1-cd03.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd new file mode 100644 index 0000000000..011c7a61ea --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-c-1.1-cd04.xsd @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd new file mode 100644 index 0000000000..e0524ee006 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-composite-1.1-cd04.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd new file mode 100644 index 0000000000..777da1e8ab --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-cpp-1.1-cd04.xsd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd new file mode 100644 index 0000000000..53f6a0a51a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-java-1.1-cd03.xsd @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd new file mode 100644 index 0000000000..51327ec84e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-implementation-spring-1.1-cd01.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd new file mode 100644 index 0000000000..045118cb43 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-c-1.1-cd04.xsd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd new file mode 100644 index 0000000000..536b592c04 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-cpp-1.1-cd04.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd new file mode 100644 index 0000000000..faf6d1cfb1 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-java-1.1-cd04.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd new file mode 100644 index 0000000000..980e4f90f5 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-interface-wsdl-1.1-cd04.xsd @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd new file mode 100644 index 0000000000..6df685b881 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-jee-1.1-wd03.xsd @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd new file mode 100644 index 0000000000..a6cdfb2be5 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/sca-policy-1.1-cd04.xsd @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd new file mode 100644 index 0000000000..de7bc6bdd0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-dwr.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd new file mode 100644 index 0000000000..ce8d47b575 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-http.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd new file mode 100644 index 0000000000..92142d117d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-jsonrpc.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd new file mode 100644 index 0000000000..9b15010624 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-binding-rmi.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd new file mode 100644 index 0000000000..dfe819d97f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1-implementation-osgi.xsd @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd new file mode 100644 index 0000000000..7a8f45954f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly-xsd/src/main/resources/tuscany-sca-1.1.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/LICENSE b/branches/sca-java-2.0-M4/modules/assembly/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/assembly/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..a6327b2c98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/NOTICE b/branches/sca-java-2.0-M4/modules/assembly/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/pom.xml b/branches/sca-java-2.0-M4/modules/assembly/pom.xml new file mode 100644 index 0000000000..79965b9e57 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly/pom.xml @@ -0,0 +1,45 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-assembly + Apache Tuscany SCA Assembly Model + + + + + org.apache.tuscany.sca + tuscany-monitor + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-extensibility + 2.0-M4-SNAPSHOT + + + + diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractContract.java new file mode 100644 index 0000000000..30e2592008 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractProperty.java new file mode 100644 index 0000000000..fcad39d8cb --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractReference.java new file mode 100644 index 0000000000..a9ef26bbb9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AbstractService.java new file mode 100644 index 0000000000..9ae511c07b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/AssemblyFactory.java new file mode 100644 index 0000000000..7c0f7cf2ce --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java new file mode 100644 index 0000000000..96dc906395 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java new file mode 100644 index 0000000000..5c5827637d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/BindingRRB.java new file mode 100644 index 0000000000..35e5f148ba --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Callback.java new file mode 100644 index 0000000000..d34ec7d01f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getBindings(); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Component.java new file mode 100644 index 0000000000..e2a68e2a4d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentProperty.java new file mode 100644 index 0000000000..9a6ae4d35a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentReference.java new file mode 100644 index 0000000000..b204b649fe --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentService.java new file mode 100644 index 0000000000..022d829488 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ComponentType.java new file mode 100644 index 0000000000..2a09b5bc6f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 getProperties(); + + /** + * Return a property by name + * + * @param name the property name + * @return property the property + */ + Property getProperty(String name); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java new file mode 100644 index 0000000000..64a55f1b44 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getIncludes(); + + /** + * Returns a list of components contained in this composite. + * + * @return a list of components contained in this composite + */ + List 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeReference.java new file mode 100644 index 0000000000..88cb2f9a2c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPromotedComponents(); + + /** + * Returns the promoted component references. + * + * @return the promoted component references + */ + List getPromotedReferences(); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/CompositeService.java new file mode 100644 index 0000000000..690316aca4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/ConfiguredOperation.java new file mode 100644 index 0000000000..9c8f6db912 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java new file mode 100644 index 0000000000..731c2986b5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getBindings(); + + /** + * Returns a binding of the specified type or null if there is no such + * binding configured on this contract. + * + * @param the binding type + * @param bindingClass the binding type class + * @return the binding or null if there is no binding of the specified type + */ + B getBinding(Class bindingClass); + + /** + * Returns a callback binding of the specified type or null if there is no such + * callback binding configured on this contract. + * + * @param 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 getCallbackBinding(Class 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DefaultAssemblyFactory.java new file mode 100644 index 0000000000..6d8350fc66 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java new file mode 100644 index 0000000000..5cc43d6333 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Endpoint.java new file mode 100644 index 0000000000..59ab8d36fc --- /dev/null +++ b/branches/sca-java-2.0-M4/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 <componentURI>#service-binding(serviceName/bindingName) + * or <componentURI>#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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/EndpointReference.java new file mode 100644 index 0000000000..7b547e70de --- /dev/null +++ b/branches/sca-java-2.0-M4/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 <componentURI>#reference-binding(referenceName/bindingName) + * or <componentURI>#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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extensible.java new file mode 100644 index 0000000000..9476251305 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getExtensions(); + + /** + * Returns a list of attribute extensions contained in this model object + * + * @return a list of attribute extensions contained in this model object + */ + List getAttributeExtensions(); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Extension.java new file mode 100644 index 0000000000..4d5b1a2ecd --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getValue(); + + /** + * Set the original extension value + * @param value the extension value + */ + 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java new file mode 100644 index 0000000000..2d918a0592 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getOperations(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Multiplicity.java new file mode 100644 index 0000000000..5d15ce9938 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationSelector.java new file mode 100644 index 0000000000..f72b78cc3a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OperationsConfigurator.java new file mode 100644 index 0000000000..947fcd4c7c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getConfiguredOperations(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/OptimizableBinding.java new file mode 100644 index 0000000000..f997d03786 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Property.java new file mode 100644 index 0000000000..9d1b3ac20c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java new file mode 100644 index 0000000000..702826d43e --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 getEndpointReferences(); + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java new file mode 100644 index 0000000000..aa356e3857 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABindingFactory.java new file mode 100644 index 0000000000..176770e553 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Service.java new file mode 100644 index 0000000000..5069b92a50 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getEndpoints(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Wire.java new file mode 100644 index 0000000000..075b50eec1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/WireFormat.java new file mode 100644 index 0000000000..fc03bfeb88 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java new file mode 100644 index 0000000000..5f10af6510 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + /** + * 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderContext.java new file mode 100644 index 0000000000..8a16fac9e4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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> bindingBaseURIs = Collections.emptyMap(); + protected Monitor monitor; + + /** + * @param definitions + * @param bindingBaseURIs + * @param monitor + */ + public BuilderContext(Definitions definitions, Map> 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> getBindingBaseURIs() { + return bindingBaseURIs; + } + + public void setDefinitions(Definitions definitions) { + this.definitions = definitions; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BuilderExtensionPoint.java new file mode 100644 index 0000000000..ae526b92a1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 + * @param bindingType + * @return + */ + BindingBuilder getBindingBuilder(QName bindingType); + + /** + * Remove a binding builder + * @param + * @param builder + */ + void removeBindingBuilder(BindingBuilder builder); + + /** + * Add an implementation builder + * @param implementationBuilder + */ + void addImplementationBuilder(ImplementationBuilder implementationBuilder); + + /** + * Look up an implementation builder by implementation type + * @param + * @param implementationType + * @return + */ + ImplementationBuilder getImplementationBuilder(QName implementationType); + + /** + * Remove an implementation builder + * @param + * @param builder + */ + void removeImplementationBuilder(ImplementationBuilder builder); + + /** + * Add a policy builder + * @param policyBuilder + */ + void addPolicyBuilder(PolicyBuilder policyBuilder); + + /** + * Look up a Policy builder by the Policy type + * @param

+ * @param policyType + * @return + */ +

PolicyBuilder

getPolicyBuilder(QName policyType); + + /** + * Remove a Policy builder + * @param

+ * @param builder + */ +

void removePolicyBuilder(PolicyBuilder

builder); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilder.java new file mode 100644 index 0000000000..50bf10f54a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderException.java new file mode 100644 index 0000000000..5a2015f55e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultBuilderExtensionPoint.java new file mode 100644 index 0000000000..6d85405861 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 builders = new HashMap(); + private final Map bindingBuilders = new HashMap(); + private final Map implementationBuilders = + new HashMap(); + private final Map policyBuilders = new HashMap(); + + 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 builderDeclarations; + ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance(); + try { + builderDeclarations = serviceDiscovery.getServiceDeclarations(CompositeBuilder.class.getName()); + } catch (Exception e) { + throw new IllegalStateException(e); + } + + for (ServiceDeclaration builderDeclaration : builderDeclarations) { + Map 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 BindingBuilder getBindingBuilder(QName bindingType) { + loadBuilders(); + return (BindingBuilder)bindingBuilders.get(bindingType); + } + + public void removeBindingBuilder(BindingBuilder builder) { + bindingBuilders.remove(builder.getBindingType()); + } + + public void addImplementationBuilder(ImplementationBuilder implementationBuilder) { + implementationBuilders.put(implementationBuilder.getImplementationType(), implementationBuilder); + } + + public ImplementationBuilder getImplementationBuilder(QName implementationType) { + loadBuilders(); + return (ImplementationBuilder)implementationBuilders.get(implementationType); + } + + public void removeImplementationBuilder(ImplementationBuilder builder) { + implementationBuilders.remove(builder.getImplementationType()); + } + + public void addPolicyBuilder(PolicyBuilder policyBuilder) { + policyBuilders.put(policyBuilder.getPolicyType(), policyBuilder); + } + + public PolicyBuilder getPolicyBuilder(QName policyType) { + loadBuilders(); + return (PolicyBuilder)policyBuilders.get(policyType); + } + + public void removePolicyBuilder(PolicyBuilder 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 builderClass = (Class)builderDeclaration.loadClass(); + try { + Constructor constructor = + builderClass.getConstructor(FactoryExtensionPoint.class, InterfaceContractMapper.class); + builder = constructor.newInstance(factories, mapper); + } catch (NoSuchMethodException e) { + try { + Constructor constructor = + builderClass.getConstructor(BuilderExtensionPoint.class, + FactoryExtensionPoint.class, + InterfaceContractMapper.class); + builder = constructor.newInstance(builders, factories, mapper); + } catch (NoSuchMethodException ex) { + Constructor 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DomainBuilder.java new file mode 100644 index 0000000000..6fa2d18037 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java new file mode 100644 index 0000000000..b1e22e195d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + + /** + * 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/Messages.java new file mode 100644 index 0000000000..d40d72ae98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/PolicyBuilder.java new file mode 100644 index 0000000000..2df42c2c23 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java new file mode 100644 index 0000000000..49995f5ab8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java new file mode 100644 index 0000000000..3e44f5f7ae --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java new file mode 100644 index 0000000000..24b1a0e03e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java new file mode 100644 index 0000000000..0759ff1361 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java new file mode 100644 index 0000000000..516b11724f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java new file mode 100644 index 0000000000..552d67fec6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + + protected QName type; + + protected BindingImpl(QName type) { + super(); + this.type = type; + } + + public QName getType() { + return type; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java new file mode 100644 index 0000000000..dcd6c7b08a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 bindings = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + + public List getPolicySets() { + return policySets; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + protected CallbackImpl() { + } + + public List getBindings() { + return bindings; + } + + public ExtensionType getExtensionType() { + return null; + } + + public void setExtensionType(ExtensionType type) { + } + + public void setRequiredIntents(List intents) { + this.requiredIntents = intents; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java new file mode 100644 index 0000000000..8a03df339c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 properties = new ArrayList(); + private List references = new ArrayList(); + private List services = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + 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(); + for (ComponentProperty property : getProperties()) { + clone.properties.add((ComponentProperty)property.clone()); + } + clone.references = new ArrayList(); + for (ComponentReference reference : getReferences()) { + clone.references.add((ComponentReference)reference.clone()); + } + clone.services = new ArrayList(); + 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(getRequiredIntents()); + clone.policySets = new ArrayList(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 getProperties() { + return properties; + } + + public ComponentProperty getProperty(String name) { + for (ComponentProperty property : getProperties()) { + if (property.getName().equals(name)) { + return property; + } + } + return null; + } + + public List getReferences() { + return references; + } + + public ComponentReference getReference(String name){ + for (ComponentReference ref : getReferences()){ + if (ref.getName().equals(name)){ + return ref; + } + } + return null; + } + + public List 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 getRequiredIntents() { + return requiredIntents; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java new file mode 100644 index 0000000000..9db522930f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java new file mode 100644 index 0000000000..78b54668b3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 promotedAs = new ArrayList(); + 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java new file mode 100644 index 0000000000..f8c9f53413 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 promotedAs = new ArrayList(); + 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 promotedAs() { + return promotedAs; + } + + public ComponentReference getCallbackReference() { + return callbackReference; + } + + public void setCallbackReference(ComponentReference callbackReference) { + this.callbackReference = callbackReference; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java new file mode 100644 index 0000000000..f18c852e69 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 properties = new ArrayList(); + private List references = new ArrayList(); + private List services = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + + /** + * Constructs a new component type. + */ + protected ComponentTypeImpl() { + } + + @Override + public Object clone() throws CloneNotSupportedException { + ComponentTypeImpl clone = (ComponentTypeImpl)super.clone(); + + clone.services = new ArrayList(); + for (Service service : getServices()) { + clone.services.add((Service)service.clone()); + } + clone.references = new ArrayList(); + for (Reference reference : getReferences()) { + clone.references.add((Reference)reference.clone()); + } + clone.properties = new ArrayList(); + for (Property property : getProperties()) { + clone.properties.add((Property)property.clone()); + } + clone.requiredIntents = new ArrayList(requiredIntents); + clone.policySets = new ArrayList(policySets); + return clone; + } + + public String getURI() { + return uri; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public List 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 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 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 getRequiredIntents() { + return requiredIntents; + } + + public List getPolicySets() { + return policySets; + } + + public ExtensionType getExtensionType() { + return null; + } + + public void setExtensionType(ExtensionType type) { + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java new file mode 100644 index 0000000000..fba6af7e7f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 components = new ArrayList(); + private List includes = new ArrayList(); + private QName name; + private List wires = new ArrayList(); + 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(); + 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(); + for (Wire wire : getWires()) { + clone.wires.add((Wire)wire.clone()); + } + + // Clone the includes + clone.includes = new ArrayList(); + 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 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 getIncludes() { + return includes; + } + + public QName getName() { + return name; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeReferenceImpl.java new file mode 100644 index 0000000000..ae5fad461b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 promotedComponents = new ArrayList(); + private List promotedReferences = new ArrayList(); + + /** + * Constructs a new composite reference. + */ + protected CompositeReferenceImpl() { + } + + @Override + public Object clone() throws CloneNotSupportedException { + CompositeReferenceImpl copy = (CompositeReferenceImpl)super.clone(); + copy.promotedComponents = new ArrayList(promotedComponents); + copy.promotedReferences = new ArrayList(promotedReferences); + return copy; + } + + public List getPromotedReferences() { + return promotedReferences; + } + + public List getPromotedComponents() { + return promotedComponents; + } + + public String toString() { + return getName(); + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeServiceImpl.java new file mode 100644 index 0000000000..55b48ec578 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConfiguredOperationImpl.java new file mode 100644 index 0000000000..32377faf54 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List applicablePolicySets = new ArrayList(); + + private String name; + private String contractName; + private ExtensionType type; + + /** + * Constructs a new Operation. + */ + protected ConfiguredOperationImpl() { + } + + public List getPolicySets() { + return policySets; + } + + public void setPolicySets(List policySets) { + this.policySets = policySets; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public void setRequiredIntents(List intents) { + this.requiredIntents = intents; + } + + public String getContractName() { + return contractName; + } + + public void setContractName(String contractName) { + this.contractName = contractName; + } + + public List getApplicablePolicySets() { + return applicablePolicySets; + } + + public ExtensionType getExtensionType() { + return type; + } + + public void setExtensionType(ExtensionType type) { + this.type = type; + } + + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java new file mode 100644 index 0000000000..2b72f1f047 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + + 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 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 getPolicySets() { + return policySets; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java new file mode 100644 index 0000000000..99d68a11bc --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java new file mode 100644 index 0000000000..4b1d9e437d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 callbackEndpointReferences = new ArrayList(); + protected List policySets = new ArrayList(); + protected List requiredIntents = new ArrayList(); + 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 getCallbackEndpointReferences() { + resolve(); + return callbackEndpointReferences; + } + + public List getPolicySets() { + resolve(); + return policySets; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java new file mode 100644 index 0000000000..4c02be42dd --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policySets = new ArrayList(); + protected List requiredIntents = new ArrayList(); + 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 getPolicySets() { + resolve(); + return policySets; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensibleImpl.java new file mode 100644 index 0000000000..340fa2854c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensions = new ArrayList(); + private List attributeExtensions = new ArrayList(); + + /** + * Constructs a new base model object. + */ + protected ExtensibleImpl() { + } + + public List getExtensions() { + return extensions; + } + + public List getAttributeExtensions() { + return attributeExtensions; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ExtensionImpl.java new file mode 100644 index 0000000000..b5018c4d43 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getValue() { + return (T)value; + } + + public void setValue(T value) { + this.value = value; + } + + public boolean isAttribute() { + return isAttribute; + } + + public void setAttribute(boolean isAttribute) { + this.isAttribute = isAttribute; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java new file mode 100644 index 0000000000..20c7ea3206 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 operations = new ArrayList(); + + 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 getOperations() { + return operations; + } + + @Override + public Object clone() throws CloneNotSupportedException { + ImplementationImpl impl = (ImplementationImpl)super.clone(); + impl.operations = new ArrayList(); + for (Operation operation : operations) { + impl.operations.add((Operation)operation.clone()); + } + return impl; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/PropertyImpl.java new file mode 100644 index 0000000000..263af296b1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policySets = new ArrayList(); + private List applicablePolicySets = new ArrayList(); + + /** + * Constructs a new property. + */ + protected PropertyImpl() { + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public List getPolicySets() { + return policySets; + } + + public void setPolicySets(List policySets) { + this.policySets = policySets; + } + + public List getApplicablePolicySets() { + return applicablePolicySets; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java new file mode 100644 index 0000000000..af4b3559c5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 bindings = new ArrayList(); + private boolean wiredByImpl; + private List targets = new ArrayList(); + private Callback callback; + private boolean promotionOverride; + private boolean overridingBindings; + private List endpointReferences = new ArrayList(); + + /** + * Constructs a new reference. + */ + protected ReferenceImpl() { + } + + @Override + public Object clone() throws CloneNotSupportedException { + ReferenceImpl clone = (ReferenceImpl)super.clone(); + clone.bindings = new ArrayList(bindings); + clone.targets = new ArrayList(targets); + // clone the endpoint references themselves and set the reference pointer back to + // this new refrence + clone.endpointReferences = new ArrayList(); + + for (EndpointReference epr : endpointReferences) { + EndpointReference eprClone = (EndpointReference)epr.clone(); + eprClone.setReference((ComponentReference)clone); + clone.endpointReferences.add(eprClone); + } + return clone; + } + + public List getBindings() { + return bindings; + } + + public B getBinding(Class bindingClass) { + for (Binding binding : bindings) { + if (bindingClass.isInstance(binding)) { + return bindingClass.cast(binding); + } + } + return null; + } + + public B getCallbackBinding(Class 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 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 getEndpointReferences() { + return endpointReferences; + } + + public String toString() { + return getName(); + } + + public boolean isOverridingBindings() { + return overridingBindings; + } + + public void setOverridingBindings(boolean overridingBindings) { + this.overridingBindings = overridingBindings; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingFactoryImpl.java new file mode 100644 index 0000000000..cf7e744e88 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java new file mode 100644 index 0000000000..b67dbcbb12 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensions = new ArrayList(); + private List attributeExtensions = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + private ExtensionType extensionType; + + private Component targetComponent; + private ComponentService targetComponentService; + private Binding targetBinding; + private List applicablePolicySets = new ArrayList(); + + public List 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 getExtensions() { + return extensions; + } + + public List getAttributeExtensions() { + return attributeExtensions; + } + + public boolean isUnresolved() { + if (targetComponentService == null) { + return true; + } else { + return targetComponentService.isUnresolved(); + } + } + + public void setUnresolved(boolean unresolved) { + } + + public List getPolicySets() { + return policySets; + } + + public List 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 policySets) { + this.policySets = policySets; + } + + public void setRequiredIntents(List intents) { + this.requiredIntents = intents; + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public QName getType() { + return TYPE; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java new file mode 100644 index 0000000000..62523e5c17 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 bindings = new ArrayList(); + private boolean overridingBindings; + private Callback callback; + private List endpoints = new ArrayList(); + + /** + * Constructs a new service. + */ + protected ServiceImpl() { + } + + @Override + public Object clone() throws CloneNotSupportedException { + ServiceImpl clone = (ServiceImpl)super.clone(); + clone.bindings = new ArrayList(); + clone.bindings.addAll(getBindings()); + return clone; + } + + public List getBindings() { + return bindings; + } + + public B getBinding(Class bindingClass) { + for (Binding binding : bindings) { + if (bindingClass.isInstance(binding)) { + return bindingClass.cast(binding); + } + } + return null; + } + + public B getCallbackBinding(Class 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 getEndpoints() { + return endpoints; + } + + public boolean isOverridingBindings() { + return overridingBindings; + } + + public void setOverridingBindings(boolean overridingBindings) { + this.overridingBindings = overridingBindings; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java new file mode 100644 index 0000000000..a4990f6a98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + private List applicablePolicySets = new ArrayList(); + + public List 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 getRequiredIntents() { + return requiredIntents; + } + + public List getPolicySets() { + return policySets; + } + + public ExtensionType getExtensionType() { + return null; + } + + public void setExtensionType(ExtensionType type) { + } + + public void setPolicySets(List policySets) { + this.policySets = policySets; + } + + public void setRequiredIntents(List intents) { + this.requiredIntents = intents; + } + + public boolean isReplace() { + return replace; + } + + public void setReplace(boolean replace) { + this.replace = replace; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefaultDefinitionsFactory.java new file mode 100644 index 0000000000..156fd0af75 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/Definitions.java new file mode 100644 index 0000000000..7a63bbedc5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getIntents(); + + /** + * Returns a list of domain wide PolicySets + * + * @return a list of domain wide PolicySets + */ + List getPolicySets(); + + /** + * Returns a list of domain wide Binding Types + * + * @return a list of domain wide Binding Types + */ + List getBindingTypes(); + + + /** + * Returns a list of domain wide Implementation Types + * + * @return a list of domain wide Implementation Types + */ + List getImplementationTypes(); + + /** + * Returns a list of domain wide binding definition objects + * + * @return a list of domain wide binding definition objects + */ + List getBindings(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilder.java new file mode 100644 index 0000000000..5c68c6cbff --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsBuilderException.java new file mode 100644 index 0000000000..f45be80888 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/DefinitionsFactory.java new file mode 100644 index 0000000000..616616ae7a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsBuilderImpl.java new file mode 100644 index 0000000000..d87d45b27a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 definedIntents = new HashMap(); + for (Intent intent : scaDefns.getIntents()) { + definedIntents.put(intent.getName(), intent); + } + + Map definedPolicySets = new HashMap(); + for (PolicySet policySet : scaDefns.getPolicySets()) { + definedPolicySets.put(policySet.getName(), policySet); + } + + Map definedBindingTypes = new HashMap(); + for (BindingType bindingType : scaDefns.getBindingTypes()) { + definedBindingTypes.put(bindingType.getType(), bindingType); + } + + Map definedImplTypes = new HashMap(); + 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 definedBindingTypes, + Map definedIntents) throws DefinitionsBuilderException { + for (BindingType bindingType : scaDefns.getBindingTypes()) { + buildAlwaysProvidedIntents(bindingType, definedIntents); + buildMayProvideIntents(bindingType, definedIntents); + } + + } + + private void buildImplementationTypes(Definitions scaDefns, + Map definedImplTypes, + Map definedIntents) throws DefinitionsBuilderException { + for (ImplementationType implType : scaDefns.getImplementationTypes()) { + buildAlwaysProvidedIntents(implType, definedIntents); + buildMayProvideIntents(implType, definedIntents); + } + } + + private void buildPolicyIntents(Definitions scaDefns, Map 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 definedPolicySets, + Map 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 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 requiredIntents = new ArrayList(); + 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 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 definedIntents) + throws DefinitionsBuilderException { + if (extensionType != null) { + // resolve all provided intents + List alwaysProvided = new ArrayList(); + 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 definedIntents) + throws DefinitionsBuilderException { + if (extensionType != null) { + // resolve all provided intents + List mayProvide = new ArrayList(); + 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 definedIntents) + throws DefinitionsBuilderException { + if (policySet != null) { + //resolve all provided intents + List providedIntents = new ArrayList(); + 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 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 definedPolicySets) + throws DefinitionsBuilderException { + + List referredPolicySets = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/impl/DefinitionsImpl.java new file mode 100644 index 0000000000..224bc0a69a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 intents = new CopyOnWriteArrayList(); + private List policySets = new CopyOnWriteArrayList(); + private List bindingTypes = new CopyOnWriteArrayList(); + private List implementationTypes = new CopyOnWriteArrayList(); + private List bindings = new CopyOnWriteArrayList(); + + + public List getBindingTypes() { + return bindingTypes; + } + + public List getImplementationTypes() { + return implementationTypes; + } + + public List getIntents() { + return intents; + } + + public List getPolicySets() { + return policySets; + } + + public String getTargetNamespace() { + return targetNamespace; + } + + public void setTargetNamespace(String ns) { + this.targetNamespace = ns; + } + + public List getBindings() { + return bindings; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/definitions/util/DefinitionsUtil.java new file mode 100644 index 0000000000..ead5ecba72 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 intents = new HashSet(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 policySets = new HashSet(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 bindingTypes = new HashSet(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 implementationTypes = new HashSet(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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ConversationSequence.java new file mode 100644 index 0000000000..247a432330 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/DataType.java new file mode 100644 index 0000000000..1f5620c0b9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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: + *
    + *
  • a Class identifies a Java type by name and + * ClassLoader; this includes Java Classes as they are specializations of + * Type
  • + *
  • a XMLType identifies an XML type by local name and + * namespace
  • + *
+ * + * @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 getMetaData(Class 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 + */ + void setMetaData(Class type, T metaData); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/FaultExceptionMapper.java new file mode 100644 index 0000000000..70f6d5b403 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/IncompatibleInterfaceContractException.java new file mode 100644 index 0000000000..179dc1755e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Interface.java new file mode 100644 index 0000000000..cab7057b57 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 + * 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 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 getAttributes(); + + /** + * Implementations must support cloning. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContract.java new file mode 100644 index 0000000000..568a6c595c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java new file mode 100644 index 0000000000..8dfeb29833 --- /dev/null +++ b/branches/sca-java-2.0-M4/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. + *

+ * 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:

+ *

    + *
  1. the source interface and the target interface MUST either both be + * remotable or they are both local + *
  2. 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 + *
  3. 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. + *
  4. the order of the input and output types also MUST BE the same. + *
  5. the set of Faults and Exceptions expected by the source MUST BE the + * same or be a superset of those specified by the service. + *
  6. other specified attributes of the two interfaces MUST match, + * including Scope and Callback interface + *
+ *

+ *

+ * 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 + *

+ *

+ * 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. + *

    + *
  • source's logical type is either the same or subtype of the target's + * logical type + *
+ * 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidAnnotationException.java new file mode 100644 index 0000000000..b24872bf96 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidCallbackException.java new file mode 100644 index 0000000000..f952a86478 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidInterfaceException.java new file mode 100644 index 0000000000..2a273c9a26 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InvalidOperationException.java new file mode 100644 index 0000000000..b19805c5b1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/Operation.java new file mode 100644 index 0000000000..55f00b82c8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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> getInputType(); + + /** + * @param inputType + */ + void setInputType(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 getFaultTypes(); + + /** + * @param faultTypes + */ + void setFaultTypes(List 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>> getFaultBeans(); + + /** + * Set the synthesized fault beans for this operation + * @param faultBeans + */ + void setFaultBeans(Map>> faultBeans); + + /** + * Get a map of attributes assoicated with the operation + * @return A map of attributes + */ + Map getAttributes(); + + /** + * Implementations must support cloning. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/OverloadedOperationException.java new file mode 100644 index 0000000000..6773b29088 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/DataTypeImpl.java new file mode 100644 index 0000000000..c1c8400b71 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 implements DataType { + private String dataBinding; + private Class physical; + private Type genericType; + private L logical; + private Map, 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: + *
    + *
  • a java.lang.reflect.Type identifies a Java type by name and + * ClassLoader; this includes Java Classes as they are specializations of + * Type
  • + *
  • a javax.xml.namespace.QName identifies an XML type by local name and + * namespace
  • + *
+ * + * @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 getMetaData(Class type) { + return metaDataMap == null ? null : type.cast(metaDataMap.get(type)); + } + + public void setMetaData(Class type, T metaData) { + if (metaDataMap == null) { + metaDataMap = new ConcurrentHashMap, Object>(); + } + metaDataMap.put(type, metaData); + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractImpl.java new file mode 100644 index 0000000000..15581b5e04 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java new file mode 100644 index 0000000000..289fd25594 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java new file mode 100644 index 0000000000..08f859fc8a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private Map attributes = new ConcurrentHashMap(); + + 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 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 { + 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 c) { + for (Operation op : c) { + op.setInterface(InterfaceImpl.this); + } + return super.addAll(c); + } + + @Override + public boolean addAll(int index, Collection 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> 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 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> 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> 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 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> 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 getPolicySets() { + return policySets; + } + + public List 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(); + copy.attributes.putAll(attributes); + return copy; + } + + public Map getAttributes() { + return attributes; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java new file mode 100644 index 0000000000..26144e92cb --- /dev/null +++ b/branches/sca-java-2.0-M4/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> inputType; + private List faultTypes; + private Interface interfaze; + private ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; + private boolean nonBlocking; + private boolean wrapperStyle; + private WrapperInfo wrapper; + private boolean dynamic; + + private Map attributes = new ConcurrentHashMap(); + + private Map>> faultBeans; + + private List applicablePolicySets = new ArrayList(); + private List policySets = new ArrayList(); + private List requiredIntents = new ArrayList(); + private ExtensionType type; + + /** + * @param name + */ + public OperationImpl() { + inputType = new DataTypeImpl>("idl:input", Object[].class, new ArrayList()); + faultTypes = new ArrayList(); + faultBeans = new HashMap>>(); + } + + 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 getFaultTypes() { + return faultTypes; + } + + /** + * @param faultTypes the faultTypes to set + */ + public void setFaultTypes(List faultTypes) { + this.faultTypes = faultTypes; + } + + /** + * @return the inputType + */ + public DataType> getInputType() { + return inputType; + } + + /** + * @param inputType the inputType to set + */ + public void setInputType(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>> getFaultBeans() { + return faultBeans; + } + + public void setFaultBeans(Map>> faultBeans) { + this.faultBeans = faultBeans; + } + + @Override + public OperationImpl clone() throws CloneNotSupportedException { + OperationImpl copy = (OperationImpl) super.clone(); + + final List clonedFaultTypes = new ArrayList(this.faultTypes.size()); + for (DataType t : this.faultTypes) { + clonedFaultTypes.add((DataType) t.clone()); + } + copy.faultTypes = clonedFaultTypes; + + List clonedLogicalTypes = new ArrayList(); + for (DataType t : inputType.getLogical()) { + DataType type = (DataType) t.clone(); + clonedLogicalTypes.add(type); + } + DataType> clonedInputType = + new DataTypeImpl>(inputType.getPhysical(), clonedLogicalTypes); + clonedInputType.setDataBinding(inputType.getDataBinding()); + copy.inputType = clonedInputType; + + if (this.outputType != null) { + copy.outputType = (DataType) this.outputType.clone(); + } + + copy.attributes = new ConcurrentHashMap(); + copy.attributes.putAll(attributes); + + return copy; + } + + public List getApplicablePolicySets() { + return applicablePolicySets; + } + + public List getPolicySets() { + return policySets; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public ExtensionType getExtensionType() { + return type; + } + + public void setExtensionType(ExtensionType type) { + this.type = type; + } + + public Map getAttributes() { + return attributes; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/ElementInfo.java new file mode 100644 index 0000000000..777fa567f1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/FaultException.java new file mode 100644 index 0000000000..844b0af509 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/JavaXMLMapper.java new file mode 100644 index 0000000000..54c0a3ec11 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 JAVA2XML = new HashMap(); + private static final Map XML2JAVA = new HashMap(); + + 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/TypeInfo.java new file mode 100644 index 0000000000..2598dc8545 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/WrapperInfo.java new file mode 100644 index 0000000000..12db460959 --- /dev/null +++ b/branches/sca-java-2.0-M4/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.

+ * A WSDL operation qualifies for wrapper style mapping only if the following + * criteria are met: + *

    + *
  • (i) The operation�s input and output messages (if present) each contain + * only a single part + *
  • (ii) The input message part refers to a global element declaration whose + * localname is equal to the operation name + *
  • (iii) The output message part refers to a global element declaration + *
  • (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 + *
  • (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. + *
+ * + * @version $Rev$ $Date$ + */ +public class WrapperInfo { + private ElementInfo inputWrapperElement; + + private ElementInfo outputWrapperElement; + + private List inputChildElements; + + private List outputChildElements; + + // The data type of the unwrapped input child elements + private DataType> unwrappedInputType; + + // The data type of the unwrapped output child element (we only supports one child) + private DataType unwrappedOutputType; + + // The data for the input/output wrappers + private String dataBinding; + + // The data type for the input (request) wrapper bean + private DataType inputWrapperType; + // The data type for the output (response) wrapper bean + private DataType outputWrapperType; + + public WrapperInfo(String dataBinding, + ElementInfo inputWrapperElement, + ElementInfo outputWrapperElement, + List inputElements, + List outputElements) { + super(); + this.dataBinding = dataBinding; + this.inputWrapperElement = inputWrapperElement; + this.outputWrapperElement = outputWrapperElement; + this.inputChildElements = inputElements; + this.outputChildElements = outputElements; + } + + /** + * @return the inputElements + */ + public List getInputChildElements() { + return inputChildElements; + } + + /** + * @return the inputWrapperElement + */ + public ElementInfo getInputWrapperElement() { + return inputWrapperElement; + } + + /** + * @return the outputElements + */ + public List getOutputChildElements() { + return outputChildElements; + } + + /** + * @return the outputWrapperElement + */ + public ElementInfo getOutputWrapperElement() { + return outputWrapperElement; + } + + /** + * @return the unwrappedInputType + */ + public DataType> getUnwrappedInputType() { + if (unwrappedInputType == null) { + List childTypes = new ArrayList(); + for (ElementInfo element : getInputChildElements()) { + DataType type = getDataType(element); + childTypes.add(type); + } + unwrappedInputType = new DataTypeImpl>("idl:unwrapped.input", Object[].class, childTypes); + } + return unwrappedInputType; + } + + private DataType getDataType(ElementInfo element) { + DataType type = null; + if (element.isMany()) { + DataType logical = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + type = new DataTypeImpl("java:array", Object[].class, logical); + } else { + type = new DataTypeImpl(dataBinding, Object.class, new XMLType(element)); + } + return type; + } + + /** + * @return the unwrappedOutputType + */ + public DataType getUnwrappedOutputType() { + if (unwrappedOutputType == null) { + List 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 getInputWrapperType() { + return inputWrapperType; + } + + public void setInputWrapperType(DataType inputWrapperType) { + this.inputWrapperType = inputWrapperType; + } + + public DataType getOutputWrapperType() { + return outputWrapperType; + } + + public void setOutputWrapperType(DataType outputWrapperType) { + this.outputWrapperType = outputWrapperType; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/util/XMLType.java new file mode 100644 index 0000000000..26ecf6e352 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/BindingType.java new file mode 100644 index 0000000000..f43c428563 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/DefaultPolicyFactory.java new file mode 100644 index 0000000000..2da41675a1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ExtensionType.java new file mode 100644 index 0000000000..e7a93c8907 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/ImplementationType.java new file mode 100644 index 0000000000..d142015f57 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Intent.java new file mode 100644 index 0000000000..b79ccdab78 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getConstrainedTypes(); + + /** + * Return a list of required intents + * @return The list of required intents + */ + List getRequiredIntents(); + + /** + * Returns the list of intents which are mutually exclusive with this intent. + * + * @return the list of mutually exclusive intents. + */ + List getExcludedIntents(); + + /** + * Returns the list of qualified intents. + * + * @return the list of qualified intents. + */ + List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/IntentMap.java new file mode 100644 index 0000000000..5b401baeb3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getQualifiers(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyAttachment.java new file mode 100644 index 0000000000..ee4f5b5236 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPolicySubjects(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyExpression.java new file mode 100644 index 0000000000..a29f214f98 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPolicy(); + + /** + * Set the policy definition + * @param expression + */ + void setPolicy(T policy); + + /** + * + * @param unresolved + */ + void setUnresolved(boolean unresolved); + + /** + * + * @return + */ + boolean isUnresolved(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicyFactory.java new file mode 100644 index 0000000000..9e7de2f6da --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySet.java new file mode 100644 index 0000000000..2b5b8458d5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getReferencedPolicySets(); + + /** + * Returns the list of provided intents + * + * @return + */ + List 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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java new file mode 100644 index 0000000000..35a86ceedf --- /dev/null +++ b/branches/sca-java-2.0-M4/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: + *
    + *
  • composite + *
  • component + *
  • implementation + *
  • service + *
  • reference + *
  • binding + *
  • interface + *
+ */ +public interface PolicySubject { + /** + * Get a list of required intents + * + * @return + */ + List getRequiredIntents(); + + /** + * Get a list of attached policySets + * + * @return A list of policySets + */ + List getPolicySets(); + + ExtensionType getExtensionType(); + void setExtensionType(ExtensionType type); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/Qualifier.java new file mode 100644 index 0000000000..c1862283c7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPolicies(); +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/BindingTypeImpl.java new file mode 100644 index 0000000000..1a2a9c5bad --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ExtensionTypeImpl.java new file mode 100644 index 0000000000..97fbc19ced --- /dev/null +++ b/branches/sca-java-2.0-M4/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 alwaysProvides = new ArrayList(); + private List mayProvide = new ArrayList(); + private QName typeName; + private boolean unResolved = true; + + protected ExtensionTypeImpl() { + + } + + public List getAlwaysProvidedIntents() { + return alwaysProvides; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/ImplementationTypeImpl.java new file mode 100644 index 0000000000..5c285e4d95 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java new file mode 100644 index 0000000000..27a77f3ba8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 constrainedTypes = new ArrayList(); + private String description; + private List qualifiedIntents = new ArrayList(); + private Intent defaultQualifiedIntent; + private Intent parent; + private List requiredIntents = new ArrayList(); + private List excludedIntents = new ArrayList(); + private boolean mutuallyExclusive; + private boolean unresolved = true; + + protected IntentImpl() { + } + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public List getConstrainedTypes() { + return constrainedTypes; + } + + public void setConstrainedTypes(List 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 getQualifiedIntents() { + return qualifiedIntents; + } + + public void setQualifiedIntents(List qualifiedIntents) { + this.qualifiedIntents = qualifiedIntents; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public void setRequiredIntents(List requiredIntents) { + this.requiredIntents = requiredIntents; + } + + public List getExcludedIntents() { + return excludedIntents; + } + + public void setExcludedIntents(List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java new file mode 100644 index 0000000000..6e2941ff5c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 qualifiers = new ArrayList(); + + 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 getQualifiers() { + return qualifiers; + } +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyExpressionImpl.java new file mode 100644 index 0000000000..71e5eef6a7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPolicy() { + return (T)policy; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setName(QName name) { + this.name = name; + } + + public 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicyFactoryImpl.java new file mode 100644 index 0000000000..c67ff1eab8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/PolicySetImpl.java new file mode 100644 index 0000000000..75d1229cd8 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 providedIntents = new ArrayList(); + private List referencedPolicySets = new ArrayList(); + private boolean unresolved = true; + + private XPathExpression appliesToXPathExpression; + private XPathExpression attachToXPathExpression; + + private List intentMaps = new ArrayList(); + private List policies = new ArrayList(); + + 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 getIntentMaps() { + return intentMaps; + } + + public List getProvidedIntents() { + return providedIntents; + } + + public List getReferencedPolicySets() { + return referencedPolicySets; + } + + public List 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/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/QualifierImpl.java new file mode 100644 index 0000000000..102bea8d41 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 policies = new ArrayList(); + + protected QualifierImpl() { + } + + public Intent getIntent() { + return intent; + } + + public List getPolicies() { + return policies; + } + + public void setIntent(Intent intent) { + this.intent = intent; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java b/branches/sca-java-2.0-M4/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/util/PolicyHelper.java new file mode 100644 index 0000000000..f87938a5cb --- /dev/null +++ b/branches/sca-java-2.0-M4/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 getPolicyExpressions(PolicySubject subject, QName policyName) { + Collection policies = new ArrayList(); + for (PolicySet ps : subject.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + if (exp.getName().equals(policyName)) { + policies.add(exp); + } + } + } + return policies; + } + + public Collection getPolicies(PolicySubject subject, QName policyName) { + Collection policies = new ArrayList(); + for (PolicySet ps : subject.getPolicySets()) { + for (PolicyExpression exp : ps.getPolicies()) { + if (exp.getName().equals(policyName)) { + policies.add(exp.getPolicy()); + } + } + } + return policies; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.AssemblyFactory new file mode 100644 index 0000000000..859c4bde4b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.EndpointFactory new file mode 100644 index 0000000000..8dbff76ad9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory new file mode 100644 index 0000000000..9aabbad24e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.SCABindingFactory @@ -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.impl.SCABindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint new file mode 100644 index 0000000000..99cb59ab5d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.DefinitionsFactory new file mode 100644 index 0000000000..521d94f518 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper new file mode 100644 index 0000000000..821c58bde1 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.interfacedef.InterfaceContractMapper @@ -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.impl.InterfaceContractMapperImpl diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory b/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/META-INF/services/org.apache.tuscany.sca.policy.PolicyFactory new file mode 100644 index 0000000000..846b3b24a4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-conformance-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 element MUST reference a element in the Domain through its QName. +ASM40003=\ +The @name attribute of a child element of a MUST be unique amongst the service elements of that . +ASM40004=\ +The @name attribute of a child element of a MUST be unique amongst the reference elements of that . +ASM40005=\ +The @name attribute of a child element of a MUST be unique amongst the property elements of that . +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 child element of a MUST be unique amongst the component elements of that +ASM50002=\ +The @name attribute of a service element of a MUST be unique amongst the service elements of that +ASM50003=\ +The @name attribute of a service element of a MUST match the @name attribute of a service element of the componentType of the 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 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 MUST be unique amongst the reference elements of that + +ASM50008=\ +The @name attribute of a reference element of a MUST match the @name attribute of a reference element of the componentType of the 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 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 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 element MUST NOT contain two subelements with the same value of the @name attribute. +ASM50031=\ +The @name attribute of a property element of a MUST be unique amongst the property elements of that . +ASM50032 +If a property is single-valued, the subelement MUST NOT occur more than once. +ASM50033=\ +A property subelement MUST NOT be used when the @value attribute is used to specify the value for that property. +ASM50034=\ +If any 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 MUST match the @name attribute of a property element of the componentType of the child element of the component. +ASM50038=\ +In these cases where the types of two property elements are matched, the types declared for the two 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 element MUST be unique across all the composite services in the composite. +ASM60004=\ +A composite 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 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 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=\ + processing MUST take place before the processing of the @promote attribute of a composite reference is performed. +ASM60038=\ + processing MUST take place before the processing of the @promote attribute of a composite service is performed. +ASM60039=\ + 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 element in SCA, it MUST be treated as being bidirectional with the declared callback interface. +ASM80011=\ +If an 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 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 and 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 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 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/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages_it.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/definitions-validation-messages.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/AssemblyFactoryTestCase.java new file mode 100644 index 0000000000..20fd74d46e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java new file mode 100644 index 0000000000..5380a319d5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java new file mode 100644 index 0000000000..6777c33ff1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterface.java new file mode 100644 index 0000000000..dbe0cb8225 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestInterfaceContract.java new file mode 100644 index 0000000000..24be8a3e7d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestOperation.java new file mode 100644 index 0000000000..d94a7e93a3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/ContractCompatibilityTestCase.java new file mode 100644 index 0000000000..acdaae799e --- /dev/null +++ b/branches/sca-java-2.0-M4/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 sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + InterfaceContract target = new MockContract("FooContract"); + Operation opSource2 = newOperation("op1"); + Map targetOperations = new HashMap(); + 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 sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + InterfaceContract target = new MockContract("FooContract"); + Operation opSource2 = newOperation("op2"); + Map targetOperations = new HashMap(); + 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 sourceInputTypes = new ArrayList(); + sourceInputTypes.add(new DataTypeImpl(Object.class, Object.class)); + DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); + Operation opSource1 = newOperation("op1"); + opSource1.setInputType(inputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + List targetInputTypes = new ArrayList(); + targetInputTypes.add(new DataTypeImpl(Object.class, Object.class)); + DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); + + Operation opTarget = newOperation("op1"); + opTarget.setInputType(targetInputType); + Map targetOperations = new HashMap(); + 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 sourceInputTypes = new ArrayList(); + sourceInputTypes.add(new DataTypeImpl(Integer.class, Integer.class)); + DataType> inputType = new DataTypeImpl>(String.class, sourceInputTypes); + Operation opSource1 = newOperation("op1"); + opSource1.setInputType(inputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + List targetInputTypes = new ArrayList(); + targetInputTypes.add(new DataTypeImpl(String.class, String.class)); + DataType> targetInputType = new DataTypeImpl>(String.class, targetInputTypes); + + Operation opTarget = newOperation("op1"); + opTarget.setInputType(targetInputType); + Map targetOperations = new HashMap(); + 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 sourceInputTypes = new ArrayList(); + // sourceInputTypes.add(new DataTypeImpl(Object.class, + // Object.class)); + // DataType> inputType = new + // DataTypeImpl>(String.class, sourceInputTypes); + // Operation opSource1 = newOperationImpl("op1", inputType, null, null, + // false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // List targetInputTypes = new ArrayList(); + // targetInputTypes.add(new DataTypeImpl(String.class, + // String.class)); + // DataType> targetInputType = + // new DataTypeImpl>(String.class, targetInputTypes); + // + // Operation opTarget = newOperationImpl("op1", targetInputType, null, + // null, false, null); + // Map targetOperations = new HashMap(); + // 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(String.class, String.class); + Operation opSource1 = newOperation("op1"); + opSource1.setOutputType(sourceOutputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataTypeImpl(String.class, String.class); + Operation opTarget = newOperation("op1"); + opTarget.setOutputType(targetOutputType); + Map targetOperations = new HashMap(); + 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(Object.class, + // Object.class); + // Operation opSource1 = newOperationImpl("op1", null, + // sourceOutputType, null, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetOutputType = new DataTypeImpl(String.class, + // String.class); + // Operation opTarget = newOperationImpl("op1", null, targetOutputType, + // null, false, null); + // Map targetOperations = new HashMap(); + // 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(String.class, String.class); + Operation opSource1 = newOperation("op1"); + opSource1.setOutputType(sourceOutputType); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetOutputType = new DataTypeImpl(Integer.class, Integer.class); + Operation opTarget = newOperation("op1"); + opTarget.setOutputType(targetOutputType); + Map targetOperations = new HashMap(); + 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(String.class, String.class); + List sourceFaultTypes = new ArrayList(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = newOperation("op1"); + opSource1.setFaultTypes(sourceFaultTypes); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + DataType targetFaultType = new DataTypeImpl(String.class, String.class); + List targetFaultTypes = new ArrayList(); + targetFaultTypes.add(0, targetFaultType); + + Operation opTarget = newOperation("op1"); + opTarget.setFaultTypes(targetFaultTypes); + Map targetOperations = new HashMap(); + 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(String.class, String.class); + List sourceFaultTypes = new ArrayList(); + sourceFaultTypes.add(0, sourceFaultType); + Operation opSource1 = newOperation("op1"); + opSource1.setFaultTypes(sourceFaultTypes); + Map sourceOperations = new HashMap(); + sourceOperations.put("op1", opSource1); + source.getInterface().getOperations().addAll(sourceOperations.values()); + + InterfaceContract target = new MockContract("FooContract"); + Operation opTarget = newOperation("op1"); + Map targetOperations = new HashMap(); + 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(Exception.class, + // Exception.class); + // List sourceFaultTypes = new ArrayList(); + // sourceFaultTypes.add(0, sourceFaultType); + // Operation opSource1 = newOperationImpl("op1", null, null, + // sourceFaultTypes, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetFaultType = new + // DataTypeImpl(TuscanyException.class, TuscanyException.class); + // List targetFaultTypes = new ArrayList(); + // targetFaultTypes.add(0, targetFaultType); + // + // Operation opTarget = newOperationImpl("op1", null, null, + // targetFaultTypes, false, null); + // Map targetOperations = new HashMap(); + // 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(Exception.class, + // Exception.class); + // DataType sourceFaultType2 = new + // DataTypeImpl(RuntimeException.class, RuntimeException.class); + // List sourceFaultTypes = new ArrayList(); + // sourceFaultTypes.add(0, sourceFaultType); + // sourceFaultTypes.add(1, sourceFaultType2); + // Operation opSource1 = newOperationImpl("op1", null, null, + // sourceFaultTypes, false, null); + // Map sourceOperations = new HashMap(); + // sourceOperations.put("op1", opSource1); + // source.getInterface().getOperations().addAll(sourceOperations.values()); + // + // InterfaceContract target = new MockContract("FooContract"); + // DataType targetFaultType = new + // DataTypeImpl(TuscanyException.class, TuscanyException.class); + // List targetFaultTypes = new ArrayList(); + // targetFaultTypes.add(0, targetFaultType); + // + // Operation opTarget = newOperationImpl("op1", null, null, + // targetFaultTypes, false, null); + // Map targetOperations = new HashMap(); + // targetOperations.put("op1", opTarget); + // target.getInterface().getOperations().addAll(targetOperations.values()); + // wireService.checkCompatibility(source, target, false); + } + + private static class MockInterface extends InterfaceImpl { + + } + + private class MockContract 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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractTestCase.java new file mode 100644 index 0000000000..d1faa5cf2b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java b/branches/sca-java-2.0-M4/modules/assembly/src/test/java/org/apache/tuscany/sca/policy/PolicyFactoryTestCase.java new file mode 100644 index 0000000000..2775c4ac71 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..9d69acd1ee --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..1b9052299c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/pom.xml new file mode 100644 index 0000000000..66d8c17485 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/pom.xml @@ -0,0 +1,214 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-atom-runtime + Apache Tuscany SCA Abdera Atom Feed Binding Extension + + + + org.apache.tuscany.sca + tuscany-binding-atom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-data-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-http + 2.0-M4-SNAPSHOT + + + + javax.servlet + servlet-api + 2.5 + provided + + + + commons-httpclient + commons-httpclient + 3.1 + + + + org.apache.ws.commons.axiom + axiom-impl + 1.2.7 + runtime + + + + org.apache.abdera + abdera-core + 0.4.0-incubating + + + org.apache.geronimo.specs + geronimo-activation_1.0.2_spec + + + + + + org.apache.abdera + abdera-parser + 0.4.0-incubating + + + stax + stax-api + + + xom + xom + + + org.apache.ws.commons.axiom + axiom-impl + + + + + + org.apache.abdera + abdera-client + 0.4.0-incubating + + + + org.apache.abdera + abdera-extensions-main + 0.4.0-incubating + + + + org.apache.abdera + abdera-extensions-json + 0.4.0-incubating + + + + commons-codec + commons-codec + 1.3 + + + commons-codec + commons-codec + + + + + + commons-logging + commons-logging + runtime + 1.1.1 + + + javax.servlet + servlet-api + + + avalon-framework + avalon-framework + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + junit + junit + 4.5 + test + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/Collection.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/MediaCollection.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/collection/NotFoundException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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 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 entry = new Entry(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 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 entry = new Entry(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 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> entries = new ArrayList>(); + for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) { + Entry 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 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> entries = new ArrayList>(); + for (org.apache.abdera.model.Entry feedEntry: feed.getEntries()) { + Entry 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingListenerServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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>(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")) { + /* + + + + resource + + entries + application/atom+xml;type=entry + + + + + */ + + // 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 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 entry = new Entry(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[] collection = (Entry[])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 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 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 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 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 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return AtomBinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomBindingUtil.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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(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(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 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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>(String.class.getName(), String.class, String.class); + Class itemClass = operation.getOutputType().getPhysical(); + DataType 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/java/org/apache/tuscany/sca/binding/atom/provider/AtomServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..1b9052299c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.atom.provider.AtomBindingProviderFactory;model=org.apache.tuscany.sca.binding.atom.AtomBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AbstractProviderConsumerTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomDeleteTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomFeedNonCollectionTest.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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[] 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 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 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 createFeedEntry(String title, String content, String link) { + final Item item = new Item(title, content, link, null, new Date()); + final Entry entry = new Entry(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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomGetTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPostTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/AtomPutTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Consumer.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ConsumerProviderAtomTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ContentNegotiationTest.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerClientImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerCollectionImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 entries = new HashMap(); + 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/CustomerNonCollectionImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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[] entries; + + /** + * Default constructor + */ + public CustomerNonCollectionImpl() { + } + + /** + * Get all entries for this feed. + * + * @return All entries for this feed + */ + public Entry[] getAll() { + return entries; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 entries = new HashMap(); + private Map mediaFiles = new HashMap(); + 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) + // + // + // The Beach (REQUIRED) + // urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a (REQUIRED) + // 2005-10-07T17:17:08Z + // (REQUIRED, OPTIONAL to populate + // + // + // + // + + // 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/MediaCollectionTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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() ); + // + // + // The Beach (REQUIRED) + // urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a (REQUIRED) + // 2005-10-07T17:17:08Z + // Daffy + // (REQUIRED, OPTIONAL to populate + // + // + // + // + Document 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/Provider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderEntryEntityTagsTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + // + // + // + // Atom-Powered Robots Run Amok + // urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + // 2007-02-123T17:09:02Z + // Captain Lansing + // It's something moving... solid metal + // + + // 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 + // + // + // + // Atom-Powered Robots Run Amok + // urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + // 2007-02-123T17:09:02Z + // Captain Lansing + // It's something moving... solid metal + // + + // 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" + // + // + // + // Atom-Powered Robots Run Amok + // urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a + // 2007-02-24T16:34:06Z + // Captain Lansing + // Update: it's a hoax! + // + // 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderFeedEntityTagsTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 doc = res.getDocument(); + String body = read( res.getInputStream() ); + // RFC 4287 requires non-null id, title, updated elements + Assert.assertTrue( -1 != body.indexOf( "" )); + Assert.assertTrue( -1 != body.indexOf( "" )); + Assert.assertTrue( -1 != body.indexOf( "" )); + + 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/ProviderServiceDocumentTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 doc = res.getDocument(); + String body = read( res.getInputStream() ); + // RFC 4287 requires non-null id, title, updated elements + Assert.assertTrue( -1 != body.indexOf( "" )); + Assert.assertTrue( -1 != body.indexOf( "" )); + Assert.assertTrue( -1 != body.indexOf( "" )); + } 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 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Aggregator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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{ + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 atomFeed1; + + @Reference(required = false) + public Collection 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[] getAll() { + + // Aggregate entries from atomFeed1, atomFeed2, rssFeed1 and rssFeed2 + List entries = new ArrayList(); + 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[] query(String queryString) { + ArrayList entries = new ArrayList(); + + Entry[] allFeed = getAll(); + if (queryString.startsWith("title=")) { + String title = queryString.substring(6); + + for (Entry 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/AggregatorTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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[] 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/Sort.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 sort(List entries); +} diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/aggregator/SortImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 sort(List entries) { + Entry[] entriesArray = new Entry[entries.size()]; + entriesArray = (Entry[])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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/Headline.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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{ + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 headlines = new HashMap(); + + @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[] getAll() { + Entry[] entries = new Entry[headlines.size()]; + int i = 0; + for (Map.Entry e: headlines.entrySet()) { + entries[i++] = new Entry(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[] 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/news/NewsServiceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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[] 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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/java/org/apache/tuscany/sca/binding/atom/util/AtomTestCaseUtils.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif new file mode 100644 index 0000000000..bfeee9b2f4 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptToms.gif differ diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg new file mode 100644 index 0000000000..584f39ea8d Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/ReceiptValue.jpg differ diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Consumer.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/Provider.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ProviderNonCollection.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/ReceiptProvider.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/aggregator/FeedAggregator.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + Atom Aggregator Sample + Anonymous Aggregated Feed + anonymous + + + + + true + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom-runtime/src/test/resources/org/apache/tuscany/sca/binding/atom/news/news.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom/LICENSE b/branches/sca-java-2.0-M4/modules/binding-atom/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..3a3d6bd22b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory new file mode 100644 index 0000000000..a8117db8f3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-atom/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..00a4dfe0d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/NOTICE b/branches/sca-java-2.0-M4/modules/binding-atom/NOTICE new file mode 100644 index 0000000000..1325efd8bf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/pom.xml b/branches/sca-java-2.0-M4/modules/binding-atom/pom.xml new file mode 100644 index 0000000000..b9e4087fa8 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-atom/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-atom + Apache Tuscany SCA Atom Feed Binding Extension + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + test + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java b/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBinding.java new file mode 100644 index 0000000000..7ac6e05bc9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/AtomBindingFactory.java new file mode 100644 index 0000000000..6e5623e1a2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/src/main/java/org/apache/tuscany/sca/binding/atom/impl/AtomBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory b/branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.atom.AtomBindingFactory new file mode 100644 index 0000000000..a8117db8f3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-atom/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..00a4dfe0d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/binding-atom/src/test/java/org/apache/tuscany/sca/binding/atom/AtomBindingProcessorTestCase.java new file mode 100644 index 0000000000..6b8ff10d1a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + private XMLInputFactory inputFactory; + private StAXArtifactProcessor 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b203986264 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/pom.xml new file mode 100644 index 0000000000..93350b1b19 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/pom.xml @@ -0,0 +1,170 @@ + + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-ejb-runtime + Apache Tuscany SCA EJB Binding Runtime + + + + org.apache.tuscany.sca + tuscany-binding-ejb + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + cglib + cglib-nodep + 2.2 + compile + + + + org.apache.geronimo.specs + geronimo-ejb_3.0_spec + 1.0 + compile + + + + junit + junit + 4.5 + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.geronimo.modules + geronimo-openejb + 2.0.2 + test + + + org.apache.geronimo.modules + geronimo-connector + + + org.apache.geronimo.modules + geronimo-persistence-jpa10 + + + org.apache.openejb + openejb-ejbd + + + org.apache.openejb + openejb-server + + + org.apache.openejb + openejb-loader + + + org.apache.openejb + openejb-jee + + + org.apache.openejb + openejb-ejbd + + + org.apache.openejb + openejb-javaagent + + + com.sun.xml.bind + jaxb-impl + + + asm + asm + + + asm + asm-commons + + + + + + asm + asm-all + 3.1 + test + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + + + geronimo-repository + Geronimo Repository + http://svn.apache.org/repos/asf/geronimo/server/tags/2.0.2/repository + default + + false + + + true + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ClassLoadingUtil.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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. + *

+ * Supported names types are: + *

+ * 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[][]") + *

+ * 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. + *

+ * 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 + *

+ * type == ClassLoading.loadClass(ClassLoading.getClassName(type), classLoader) + *

+ * 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/DynamicStubClassLoader.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/Java2IDLUtil.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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. + *

+ * 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/ObjectInputStreamExt.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/StubMethodInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/corba/UtilInitializer.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 Util. + * + * @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 + * ORBInitInfo.register_initial_reference. + * + * @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. + *

+ * Calling the post_init operations is not the final + * task of ORB initialization. The final task, following the + * post_init calls, is attaching the lists of registered + * interceptors to the ORB. Therefore, the ORB does not contain the + * interceptors during calls to post_init. If an + * ORB-mediated call is made from within post_init, 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return EJBBinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/provider/EJBBindingReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 PRIMITIVE_TYPES = new HashMap(); + 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 ., the + * class .__Stub shall be used if it exists; + * otherwise, the class org.omg.stub..__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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBLocator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 ROOTS = + new HashSet(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() { + 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::/#name corbaloc:iiop::/ + * 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: <corbaname> = + * "corbaname:"<corbaloc_obj>["#"<string_name>] + * <corbaloc_obj> = <obj_addr_list> ["/"<key_string>] + * <obj_addr_list> = as defined in a corbaloc URL <key_string> = + * as defined in a corbaloc URL <string_name>= stringified Name + * empty_string Where: + *

    + *
  • corbaloc_obj: portion of a corbaname URL that identifies the naming + * context. The syntax is identical to its use in a corbaloc URL. + *
  • obj_addr_list: as defined in a corbaloc URL + *
  • key_string: as defined in a corbaloc URL. + *
  • string_name: a stringified Name with URL escapes as defined below. + *
+ * + * @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() { + 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() { + 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBObjectFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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. + *

+ * 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. + *

+ * 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. + *

+ */ + 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/EJBStubHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/InterfaceInfo.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 INTERFACES = + Collections.synchronizedMap(new WeakHashMap()); + + private static final long serialVersionUID = 2314533906465094860L; + private String name; + + private Map methods = new HashMap(); + + 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() { + 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 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/JavaReflectionAdapter.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 adapters = + Collections.synchronizedMap(new WeakHashMap()); + + private static final Map DEFAULT_VALUES = new HashMap(); + 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 methodMap = new HashMap(); + + /** + * 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() { + 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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/MethodInfo.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/java/org/apache/tuscany/sca/binding/ejb/util/NamingEndpoint.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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() { + 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::/#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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..a89f711da9 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.ejb.provider.EJBBindingProviderFactory;model=org.apache.tuscany.sca.binding.ejb.EJBBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/main/resources/binding-ejb-validation-messages.properties new file mode 100644 index 0000000000..28477dd3ac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/BankManagerFacade.java new file mode 100644 index 0000000000..337bb004b5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/Customer.java b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/Customer.java new file mode 100644 index 0000000000..8585301868 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/account/CustomerImpl.java new file mode 100644 index 0000000000..7406b9bd37 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddService.java new file mode 100644 index 0000000000..7cefba530a --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/calculator/AddServiceHome.java new file mode 100644 index 0000000000..799bcaa672 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacade.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/geronimo/samples/bank/ejb/BankManagerFacadeHome.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/EJBReferenceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/MockServer.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/java/org/apache/tuscany/sca/binding/ejb/tests/SocketTracer.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/resources/account/account.composite b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/resources/account/account.composite new file mode 100644 index 0000000000..943f82c0ed --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb-runtime/src/test/resources/account/account.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ejb/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ejb/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..a8bd2b925f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ejb/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ejb/pom.xml new file mode 100644 index 0000000000..b50745627c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb/pom.xml @@ -0,0 +1,60 @@ + + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-ejb + Apache Tuscany SCA EJB Binding Model + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBinding.java new file mode 100644 index 0000000000..cfaaeb284c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingException.java new file mode 100644 index 0000000000..6e2c8d358f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/EJBBindingFactory.java new file mode 100644 index 0000000000..13b069a6bb --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 subelement of the 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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/java/org/apache/tuscany/sca/binding/ejb/impl/EJBBindingProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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... + * + * + * ? + * ? + * + * * + * + * + * @version $Rev$ $Date$ + */ +public class EJBBindingProcessor implements StAXArtifactProcessor { + 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 + 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 getModelType() { + return EJBBinding.class; + } + + public void resolve(EJBBinding ejbBinding, ModelResolver modelResolver, ProcessorContext context) throws ContributionResolveException { + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory new file mode 100644 index 0000000000..c445a82ecb --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ejb.EJBBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.ejb.impl.EJBBindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..1e45ca9f79 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ejb/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.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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..5b26d33bb7 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/binding-ejb-validation-messages.properties new file mode 100644 index 0000000000..28477dd3ac --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ejb/src/main/resources/org/apache/tuscany/sca/binding/ejb/policy/definitions.xml @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-http-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-http-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b29dc9bc59 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-http-runtime/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-http-runtime/pom.xml new file mode 100644 index 0000000000..34145c58d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http-runtime/pom.xml @@ -0,0 +1,104 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-http-runtime + Apache Tuscany SCA HTTP Binding Runtime + + + + org.apache.tuscany.sca + tuscany-binding-http + 2.0-M4-SNAPSHOT + + + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingListenerServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return HTTPBinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPGetListenerServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceListenerServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..0fa8d44c08 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.http.provider.HTTPBindingProviderFactory;model=org.apache.tuscany.sca.binding.http.HTTPBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingCacheTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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("

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("

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("

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("

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("

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("

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("

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("

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("

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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/HTTPBindingTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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("

hey") != -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("

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("

hello") != -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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/NotModifiedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/PreconditionFailedException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestBindingCacheImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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( + ("

item=" + id + "").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( + ("

item=" + id + "").getBytes()); + } + + /** + * Implements the HTTP delete method of the collection implementation. + * @param id + * @return + */ + public InputStream delete(String id) { + return new ByteArrayInputStream( + ("

deleted item=" + id + "") + .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( + ("

deleted item=" + id + "") + .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( + ("

posted item=" + id + "") + .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( + ("

updated item=" + id + "") + .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( + ("

updated item=" + id + "") + .getBytes()); + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestGetImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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(("

item=" + id + "").getBytes()); + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceCacheImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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("

hey"); + } + + public void destroy() { + } + + public ServletConfig getServletConfig() { + return null; + } + + public String getServletInfo() { + return null; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/java/org/apache/tuscany/sca/binding/http/TestServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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("

hey"); + } + + public void destroy() { + } + + public ServletConfig getServletConfig() { + return null; + } + + public String getServletInfo() { + return null; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/content/test.html b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/content/test.html new file mode 100644 index 0000000000..f4b79d7f01 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/content/test.html @@ -0,0 +1,21 @@ + + +

hello + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/test.composite b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/test.composite new file mode 100644 index 0000000000..1fb8fce37e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/test.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/testCache.composite b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/testCache.composite new file mode 100644 index 0000000000..277556dab4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http-runtime/src/test/resources/testCache.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-http/LICENSE b/branches/sca-java-2.0-M4/modules/binding-http/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-http/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5336512666 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/NOTICE b/branches/sca-java-2.0-M4/modules/binding-http/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/pom.xml b/branches/sca-java-2.0-M4/modules/binding-http/pom.xml new file mode 100644 index 0000000000..390e7a1c2d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-http + Apache Tuscany SCA HTTP Binding Model + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + junit + junit + 4.5 + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java b/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBinding.java new file mode 100644 index 0000000000..f3f309a19b --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPBindingFactory.java new file mode 100644 index 0000000000..6ba6d8f934 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java b/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/HTTPCacheContext.java new file mode 100644 index 0000000000..372118fbf2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/impl/HTTPBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-http/src/main/java/org/apache/tuscany/sca/binding/http/xml/HTTPBindingProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + private static final String NAME = "name"; + private static final String URI = "uri"; + + private HTTPBindingFactory httpBindingFactory; + private StAXArtifactProcessor extensionProcessor; + private StAXAttributeProcessor extensionAttributeProcessor; + + + public HTTPBindingProcessor(ExtensionPointRegistry extensionPoints, + StAXArtifactProcessor extensionProcessor, + StAXAttributeProcessor extensionAttributeProcessor) { + FactoryExtensionPoint modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); + this.httpBindingFactory = modelFactories.getFactory(HTTPBindingFactory.class); + this.extensionProcessor = (StAXArtifactProcessor)extensionProcessor; + this.extensionAttributeProcessor = extensionAttributeProcessor; + } + + public QName getArtifactType() { + return HTTPBinding.TYPE; + } + + public Class 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/branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory b/branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory new file mode 100644 index 0000000000..44da6b166c --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.http.HTTPBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.http.impl.HTTPBindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-http/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..774637a7ae --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..fd69b62555 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/pom.xml new file mode 100644 index 0000000000..d0f5c1272d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-jms-runtime + Apache Tuscany SCA JMS Binding Runtime + + + + + org.apache.tuscany.sca + tuscany-binding-jms + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-axiom + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-wsdlgen + 2.0-M4-SNAPSHOT + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + junit + junit + 4.5 + test + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/context/JMSBindingContext.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/headers/HeaderReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSHostExtensionPoint.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListener.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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. + *

+ * What happens in the look up will depend on the create mode specified for the JMS Binding: + *

    + *
  • always - the JMS queue is always created. It is an error if the queue already exists + *
  • ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists + *
  • never - the JMS queue is never created. It is an error if the queue does not exist + *
+ * See the SCA JMS Binding specification for more information. + *

+ * + * @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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultJMSServiceListenerFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/DefaultServiceInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSHostExtensionPoint.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListener.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerDetails.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/host/JMSServiceListenerFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsdefault/runtime/OperationSelectorJMSDefaultServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + * + * + * + */ +public class OperationSelectorJMSUserPropServiceInterceptor implements Interceptor { + + private Invoker next; + private RuntimeWire runtimeWire; + private JMSBinding jmsBinding; + private OperationSelectorJMSUserProp operationSelector; + private RuntimeComponentService service; + private List 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/jmsuserprop/runtime/OperationSelectorJMSUserPropServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationPolicyProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationReferencePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/provider/JMSTokenAuthenticationServicePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderReferencePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/AbstractMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/BytesMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultJMSResourceFactoryExtensionPoint.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/DefaultMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return JMSBinding.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSBindingServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryExtensionPoint.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSResourceFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/ObjectMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/RRBJMSBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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. + *

+ * What happens in the look up will depend on the create mode specified for the JMS Binding: + *

    + *
  • always - the JMS queue is always created. It is an error if the queue already exists + *
  • ifnotexist - the JMS queue is created if it does not exist. It is not an error if the queue already exists + *
  • never - the JMS queue is never created. It is an error if the queue does not exist + *
+ * See the SCA JMS Binding specification for more information. + *

+ * + * @param isReponseQueue true if we are creating a response queue. + * false 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/TextMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLBytesMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/XMLTextMessageProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/transport/TransportServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/CallbackDestinationInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wire/OperationPropertiesInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytes/runtime/WireFormatJMSBytesServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsbytesxml/runtime/WireFormatJMSBytesXMLServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 inputWrapperMap; + private HashMap outputWrapperMap; + + public WireFormatJMSDefaultReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap inputWrapperMap, + HashMap 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 inputWrapperMap; + private HashMap 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(); + this.outputWrapperMap = new HashMap(); + + // 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 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 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 inputWrapperMap; + private HashMap outputWrapperMap; + + public WireFormatJMSDefaultServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap inputWrapperMap, + HashMap 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsdefault/runtime/WireFormatJMSDefaultServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 inputWrapperMap; + private HashMap 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(); + this.outputWrapperMap = new HashMap(); + + // 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 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 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 singleArgMap; + + public WireFormatJMSObjectReferenceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, RuntimeWire runtimeWire, HashMap 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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(); + + // 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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> singleArgMap; + private boolean wrapSingle; + + public WireFormatJMSObjectServiceInterceptor(JMSBinding jmsBinding, JMSResourceFactory jmsResourceFactory, + RuntimeWire runtimeWire, HashMap> 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmsobject/runtime/WireFormatJMSObjectServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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> 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>(); + + // 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstext/runtime/WireFormatJMSTextServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLReferenceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/jmstextxml/runtime/WireFormatJMSTextXMLServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..4cb8e90b7a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.jms.provider.JMSBindingProviderFactory;model=org.apache.tuscany.sca.binding.jms.JMSBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory new file mode 100644 index 0000000000..b3139aa400 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.OperationSelectorProviderFactory @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..3b81a75d11 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory new file mode 100644 index 0000000000..e2d0bfb6c1 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.WireFormatProviderFactory @@ -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. + +# 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldClientImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/HelloWorldServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/java/org/apache/tuscany/sca/binding/jms/OperationSelectionTestCaseFIXME.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + *

+ * 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 operations = new ArrayList(); + 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 + *

+ * 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 operations = new ArrayList(); + 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 + *

+ * 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 operations = new ArrayList(); + 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 + *

+ * 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 operations = new ArrayList(); + 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 + *

+ * 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 operations = new ArrayList(); + 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 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 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/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/client.composite b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/client.composite new file mode 100644 index 0000000000..dcea428493 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/client.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/service.composite b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/service.composite new file mode 100644 index 0000000000..44b7b29610 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms-runtime/src/test/resources/simple/service.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jms/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jms/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..54451c4d08 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms/META-INF/MANIFEST.MF @@ -0,0 +1,62 @@ +Manifest-Version: 1.0 +Export-Package: org.apache.tuscany.sca.binding.jms;version="2.0.0"; + uses:="javax.xml.stream, + org.apache.tuscany.sca.assembly, + org.apache.tuscany.sca.contribution.resolver, + org.apache.tuscany.sca.contribution.processor, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.policy, + org.apache.tuscany.sca.monitor, + javax.xml.namespace", + org.apache.tuscany.sca.binding.jms.operationselector;version="2.0.0"; + uses:="javax.xml.stream, + org.apache.tuscany.sca.assembly, + org.apache.tuscany.sca.contribution.resolver, + org.apache.tuscany.sca.contribution.processor, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.monitor, + javax.xml.namespace", + org.apache.tuscany.sca.binding.jms.policy;version="2.0.0", + org.apache.tuscany.sca.binding.jms.policy.authentication.token;version="2.0.0"; + uses:="javax.xml.stream, + org.apache.tuscany.sca.contribution.resolver, + org.apache.tuscany.sca.contribution.processor, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.monitor, + javax.xml.namespace", + org.apache.tuscany.sca.binding.jms.policy.header;version="2.0.0"; + uses:="javax.xml.stream, + org.apache.tuscany.sca.contribution.resolver, + org.apache.tuscany.sca.contribution.processor, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.monitor, + javax.xml.namespace", + org.apache.tuscany.sca.binding.jms.wireformat;version="2.0.0"; + uses:="javax.xml.stream, + org.apache.tuscany.sca.assembly, + org.apache.tuscany.sca.contribution.resolver, + org.apache.tuscany.sca.contribution.processor, + org.apache.tuscany.sca.core, + org.apache.tuscany.sca.monitor, + javax.xml.namespace" +Private-Package: org.apache.tuscany.sca.binding.jms.impl;version="2.0.0" +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: 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.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", + org.apache.tuscany.sca.binding.jms;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/branches/sca-java-2.0-M4/modules/binding-jms/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jms/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jms/pom.xml new file mode 100644 index 0000000000..f85876f7d7 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms/pom.xml @@ -0,0 +1,51 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-jms + Apache Tuscany SCA JMS Binding Model + + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/BindingProperty.java new file mode 100644 index 0000000000..c195a16ce5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBinding.java new file mode 100644 index 0000000000..8e6684b44d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 extensions = new ArrayList(); + + // properties required by PolicySetAttachPoint + private List policySets = new ArrayList(); + private List applicablePolicySets = new ArrayList(); + + // properties required by IntentAttachPoint + private List requiredIntents = new ArrayList(); + + // properties required to describe configured operations + private List configuredOperations = new ArrayList(); + + // 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 destinationProperties = new HashMap(); + + private String connectionFactoryName = null; + private String connectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + private Map connectionFactoryProperties = new HashMap(); + + private String activationSpecName = null; + private String activationSpecCreate = null; + private Map activationSpecProperties = new HashMap(); + + private String resourceAdapterName;; + private Map resourceAdapterProperties = new HashMap(); + + private String responseActivationSpecName = null; + private String responseActivationSpecCreate = null; + private Map responseActivationSpecProperties = new HashMap(); + + private String responseDestinationName = null; + private String responseDestinationType = JMSBindingConstants.DESTINATION_TYPE_QUEUE; + private String responseDestinationCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + private Map responseDestinationProperties = new HashMap(); + + private String responseConnectionFactoryName = null; + private String responseConnectionFactoryCreate = JMSBindingConstants.CREATE_IF_NOT_EXIST; + private Map responseConnectionFactoryProperties = new HashMap(); + + // 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 properties = new HashMap(); + private Map> operationProperties = new HashMap>(); + private Map nativeOperationNames = new HashMap(); + private Map operationJMSTypes = new HashMap(); + private Map operationJMSCorrelationIds = new HashMap(); + private Map operationJMSDeliveryModes = new HashMap(); + private Map operationJMSTimeToLives = new HashMap(); + private Map operationJMSPriorities = new HashMap(); + private Map> operationPropertiesProperties = new HashMap>(); + + 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 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 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 getProperties() { + return properties; + } + + /** + * Adds an operationName to this binding. + * @param opName + */ + public void addOperationName(String opName) { + Map props = operationProperties.get(opName); + if (props == null) { + props = new HashMap(); + operationProperties.put(opName, props); + } + } + + /** + * Provides set of operation names in this binding. + * @return a Set of operation names + */ + public Set getOperationNames() { + if (operationPropertiesBinding != null) { + return operationPropertiesBinding.getOperationNames(); + } else { + // Make a defensive copy since key changes affect map, map changes affect keys. + Set opNames = operationProperties.keySet(); + Set opNamesCopy = new TreeSet( opNames ); + return opNamesCopy; + } + } + + public Map 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 props = operationProperties.get(opName); + if (props == null) { + props = new HashMap(); + 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 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 getPolicySets() { + return policySets; + } + + public List getApplicablePolicySets() { + return applicablePolicySets; + } + + // operations required by IntentAttachPoint + public List getRequiredIntents() { + return requiredIntents; + } + + public QName getType() { + return TYPE; + } + + public Map getDestinationProperties() { + return destinationProperties; + } + + public Map getConnectionFactoryProperties() { + return connectionFactoryProperties; + } + + public Map getResourceAdapterProperties() { + return resourceAdapterProperties; + } + + public Map getActivationSpecProperties() { + return activationSpecProperties; + } + + public Map getResponseActivationSpecProperties() { + return responseActivationSpecProperties; + } + + public Map getResponseDestinationProperties() { + return responseDestinationProperties; + } + + public Map getResponseConnectionFactoryProperties() { + return responseConnectionFactoryProperties; + } + + public Map getOperationPropertiesProperties(String opName) { + if (operationPropertiesProperties.get(opName)==null) { + operationPropertiesProperties.put(opName, new HashMap()); + } + return operationPropertiesProperties.get(opName); + } + + public List getConfiguredOperations() { + return configuredOperations; + } + + public void setConfiguredOperations(List 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 operationNamesA = this.getOperationNames(); + Set 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 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 p1, Map 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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingConstants.java new file mode 100644 index 0000000000..80bc61baa1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingException.java new file mode 100644 index 0000000000..74f030ca21 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessor.java new file mode 100644 index 0000000000..be5673bc60 --- /dev/null +++ b/branches/sca-java-2.0-M4/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... + * + * + * + * + * * + * ? + * + * + * * + * ? + * + * + * * + * ? + * + * + * * + * ? + * + * + * + * * + * ? + * + * + * * + * ? + * + * + * * + * ? + * + * ? + * ? + * + * + * + * + * + * ? + * * + * ? + * + * + * * + * + * * + * ? + * * + * + * ? + * + * + * 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 { + private PolicyFactory policyFactory; + private PolicySubjectProcessor policyProcessor; + private ConfiguredOperationProcessor configuredOperationProcessor; + protected StAXArtifactProcessor extensionProcessor; + + + private FactoryExtensionPoint modelFactories; // DOB + public JMSBindingProcessor(FactoryExtensionPoint modelFactories, StAXArtifactProcessor 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 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)); + } + + /** + * + * * + * ? + */ + 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); + } + } + + /** + * + * * + * + * * + * ? + * * + */ + 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 props = new HashMap(); + 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 parseBindingProperties(XMLStreamReader reader, Monitor monitor) throws XMLStreamException { + Map props = new HashMap(); + 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 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. + * + * @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 + 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. + * + * * + * ? + */ + 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 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: + * StringValue + * If the value is of type box (e.g.Integer, Long) or BindingProperty, the output will be + * 42 + */ + private void writeProperties(Map 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. + * + * + * * + * + * * + * ? + * * + * + */ + private void writeOperationProperties( JMSBinding jmsBinding, XMLStreamWriter writer) throws XMLStreamException { + if (jmsBinding.getOperationPropertiesBinding() != null) { + return; + } + Set operationNames = jmsBinding.getOperationNames(); + if (operationNames == null || (operationNames.size() < 1)) { + return; + } + + for(Iterator 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 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 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: + * StringValue + * If the value is of type box (e.g.Integer, Long) or BindingProperty, the output will be + * 42 + */ + private void writeBindingProperties(Map 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. + * + * + * + * + */ + 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. + * + * * + * ? + */ + 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 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. + * + * * + * ? + */ + 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 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. + * + * * + * ? + * + */ + 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 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. + * + * * + * ? + */ + 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 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. + * + * * + * ? + * + */ + 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 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. + * + * * + * ? + * + */ + 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 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. + * ? + * * + * ? + */ + 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 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. + * " + * " + * " + * " + * " + */ + private void writeConfiguredOperations( JMSBinding jmsBinding, XMLStreamWriter writer, ProcessorContext context) throws XMLStreamException, ContributionWriteException { + List configOps = jmsBinding.getConfiguredOperations(); + if (configOps == null || (configOps.size() < 1)) { + return; + } + + for( Iterator 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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefault.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSDefaultProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return OperationSelectorJMSDefault.class; + } + + public void resolve(OperationSelectorJMSDefault arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserProp.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + * + * + * + * @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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/operationselector/OperationSelectorJMSUserPropProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return OperationSelectorJMSUserProp.class; + } + + public void resolve(OperationSelectorJMSUserProp arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicy.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/authentication/token/JMSTokenAuthenticationPolicyProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return JMSTokenAuthenticationPolicy.class; + } + + public void resolve(JMSTokenAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicy.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 properties = new Hashtable(); + + 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 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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/policy/header/JMSHeaderPolicyProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + + + 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 getModelType() { + return JMSHeaderPolicy.class; + } + + public void resolve(JMSHeaderPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytes.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSBytes.class; + } + + public void resolve(WireFormatJMSBytes arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXML.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSBytesXMLProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSBytesXML.class; + } + + public void resolve(WireFormatJMSBytesXML arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefault.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSDefaultProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSDefault.class; + } + + public void resolve(WireFormatJMSDefault arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObject.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSObjectProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSObject.class; + } + + public void resolve(WireFormatJMSObject arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSText.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSText.class; + } + + public void resolve(WireFormatJMSText arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXML.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/java/org/apache/tuscany/sca/binding/jms/wireformat/WireFormatJMSTextXMLProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return WireFormatJMSTextXML.class; + } + + public void resolve(WireFormatJMSTextXML arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..a2f226ce1a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jms/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.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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.SCADefinitionsProvider new file mode 100644 index 0000000000..0598cdc368 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-policy-validation-messages.properties new file mode 100644 index 0000000000..fd43b2c4e9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/binding-jms-validation-messages.properties new file mode 100644 index 0000000000..9361bb0e3c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jms/src/main/resources/org/apache/tuscany/sca/binding/jms/policy/definitions.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + Communication through this binding requires JMS + + + + + + + This intent is used to indicate the deliver mode + of the sent message + + + + + + Message are sent persistently + + + + + + Message are sent non-persistently + + + + + + + This intent is used to indicate the priority of the + sent message + + + + + + Messages are high priority + + + + + + Messages are medium priority + + + + + + Messages are low priority + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorTestCase.java new file mode 100644 index 0000000000..dd30d5ee6b --- /dev/null +++ b/branches/sca-java-2.0-M4/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 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String HEADERS1 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String HEADERS_INVALID_PRIORITY = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String PROPERTIES1 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " bla" + + " 42" + + " " + + " " + + " " + + " " + + ""; + + public static final String OP_PROPERTIES1 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " bla" + + " 42" + + " " + + " " + + " " + + " " + + " op2bla" + + " 77" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String OP_NAMES_NO_PROPERTIES1 = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String SELECTOR = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String COMPOSITE_INVALID_URI = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + // Invalid: contains both a response attribute and a response element. + public static final String COMPOSITE_INVALID_RESPONSE_ATTR_ELEMENT = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String DEST_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String CF_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String AS_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String RESP_DEST_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String RESP_CF_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String RESP_AS_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String OP_PROPS_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String RES_ADPT_PROPS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " some value text" + + " " + + " " + + " bla" + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String CONFIGURED_OPERATIONS = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String WIRE_FORMAT = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + public static final String OP_PROP_NAME = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + private XMLInputFactory inputFactory; + private StAXArtifactProcessor 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 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 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 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 opNames = binding.getOperationNames(); + assertEquals( 2, opNames.size() ); + // Recall that order is not guaranteed iterating over a set. + for (Iterator 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 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 opNames = binding.getOperationNames(); + assertEquals( 2, opNames.size() ); + // Recall that order is not guaranteed iterating over a set. + for (Iterator it=opNames.iterator(); it.hasNext(); ) { + String opName = it.next(); + assertTrue( opName.equals( "op1") || opName.equals( "op2")); + } + } + + /** + * Tests the APIs: + * public Set 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/branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java b/branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/JMSBindingProcessorWriteTestCase.java new file mode 100644 index 0000000000..468295df36 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 staxProcessor; + + public static final String DEFAULT = + "" + + "" + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + 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(), + "" + + "" + + "" + + "" + + " " + + "" + + "" + + " " + + " "+ + " " + + "" + + "" + + "" + + ""); + } + + 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/branches/sca-java-2.0-M4/modules/binding-jms/src/test/java/org/apache/tuscany/sca/binding/jms/policy/PolicyProcessorTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 SEQ = + Arrays.asList("property value", + ""); + + @Test + public void testRead() throws Exception { + List results = new ArrayList(); + Map processors = new HashMap(); + 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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2d32b8cf27 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/pom.xml new file mode 100644 index 0000000000..434e0bc189 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-jsonp-runtime + Apache Tuscany SCA JSONP Binding Runtime + + + + + org.apache.tuscany.sca + tuscany-binding-jsonp + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + org.codehaus.jackson + jackson-core-asl + 1.2.1 + + + org.codehaus.jackson + jackson-mapper-asl + 1.2.1 + + + + org.apache.httpcomponents + httpclient + 4.0 + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + private ServletHost servletHost; + + public JSONPBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); + List hosts = servletHosts.getServletHosts(); + if (!hosts.isEmpty()) { + this.servletHost = hosts.get(0); + } + } + + public Class 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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonp/runtime/JSONPInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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 getOrderedParameterNames(ServletRequest servletRequest) { + final String queryString = ((HttpServletRequest)servletRequest).getQueryString(); + + SortedSet sortedNames = new TreeSet(new Comparator(){ + public int compare(String o1, String o2) { + int i = queryString.indexOf(o1); + int j = queryString.indexOf(o2); + return i - j; + }}); + + Set 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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..3efe5535ce --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.jsonp.runtime.JSONPBindingProviderFactory;model=org.apache.tuscany.sca.binding.jsonp.JSONPBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..5ee1f167ea --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..99f2958d0d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..b252eddbed --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/java/test/BindingTestCase.java new file mode 100644 index 0000000000..efec56bbe3 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite new file mode 100644 index 0000000000..d058e4869f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/helloworld.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/jquery.html b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/jquery.html new file mode 100644 index 0000000000..a61cee3155 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp-runtime/src/test/resources/jquery.html @@ -0,0 +1,51 @@ + + + + Tuscany JQuery Client HelloWorld Sample + + + + + + + +

Tuscany JSONP HelloWorld Sample

+ + This example uses the JQuery getJSON to make JSONP requests to the SCA service 'HelloWorldService' + +

Enter Name:     + + + +

+ + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jsonp/LICENSE new file mode 100644 index 0000000000..6e529a25c4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jsonp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2a000f4e0a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +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: 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/branches/sca-java-2.0-M4/modules/binding-jsonp/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jsonp/NOTICE new file mode 100644 index 0000000000..51042eab05 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jsonp/pom.xml new file mode 100644 index 0000000000..7ddeb00330 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-jsonp + Apache Tuscany SCA JSONP Binding Model + + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java new file mode 100644 index 0000000000..8872d78fa6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java new file mode 100644 index 0000000000..2e8bebef0d --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory new file mode 100644 index 0000000000..480bc87d6e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.jsonp.impl.JSONPBindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..df170c1bfa --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/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.jsonp,model=org.apache.tuscany.sca.binding.jsonp.JSONPBinding,factory=org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.ValidationSchema new file mode 100644 index 0000000000..c86789135b --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/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. +# +binding-jsonp.xsd diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd new file mode 100644 index 0000000000..0817fd7969 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonp/src/main/resources/binding-jsonp.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..23ecc89c4c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/NOTICE new file mode 100644 index 0000000000..28064e5de1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/pom.xml new file mode 100644 index 0000000000..002f2f0957 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/pom.xml @@ -0,0 +1,143 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-jsonrpc-runtime + Apache Tuscany SCA JSON-RPC Binding Runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-json + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + + org.apache.httpcomponents + httpclient + 4.0 + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + org.jabsorb + jabsorb + 1.3.1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + commons-logging + commons-logging + 1.1.1 + + + commons-logging + commons-logging + + + javax.servlet + servlet-api + + + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + junit + junit + 4.5 + test + + + + httpunit + httpunit + 1.6.1 + test + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return JSONRPCBinding.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCDatabindingHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 operations = interfaze.getOperations(); + for (Operation operation : operations) { + operation.setDataBinding(JSONDataBinding.NAME); + DataType> inputType = operation.getInputType(); + if (inputType != null) { + List 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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 servletMappings = new ArrayList(); + + 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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + * + * @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 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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JavaToSmd.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..4767358e7a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.jsonrpc.provider.JSONRPCBindingProviderFactory;model=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/main/resources/org/apache/tuscany/sca/binding/jsonrpc/provider/jsonrpc.js b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/bean/TestBean.java new file mode 100644 index 0000000000..4b159fb563 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/Echo.java new file mode 100644 index 0000000000..322008de1f --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoBusinessException.java new file mode 100644 index 0000000000..bd9d905475 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoClientImpl.java new file mode 100644 index 0000000000..f76ec74b16 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/echo/EchoComponentImpl.java new file mode 100644 index 0000000000..08ccb6e6d5 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCDataTypeTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCExceptionTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCReferenceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCServiceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCSmdTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite new file mode 100644 index 0000000000..8d7a60b30f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCBinding.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite new file mode 100644 index 0000000000..0cda58286e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc-runtime/src/test/resources/JSONRPCReference.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc/LICENSE b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..f7714ece88 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/NOTICE b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/pom.xml b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/pom.xml new file mode 100644 index 0000000000..2c650e8ec9 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-jsonrpc + Apache Tuscany SCA JSON-RPC Binding Model + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBinding.java new file mode 100644 index 0000000000..1e14502d93 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/JSONRPCBindingFactory.java new file mode 100644 index 0000000000..707a9d7103 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/impl/JSONRPCBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory new file mode 100644 index 0000000000..8b9662997d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.jsonrpc.impl.JSONRPCBindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..317e4940a4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-jsonrpc/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.jsonrpc,model=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBinding,factory=org.apache.tuscany.sca.binding.jsonrpc.JSONRPCBindingFactory diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..21b3d0f6e1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/pom.xml new file mode 100644 index 0000000000..a71c5875bf --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-rmi-runtime + Apache Tuscany SCA RMI Binding Extension + + + + + org.apache.tuscany.sca + tuscany-binding-rmi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-rmi + 2.0-M4-SNAPSHOT + + + + cglib + cglib + 2.2 + + + + asm + asm + 3.1 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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() { + 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() { + 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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIBindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return RMIBinding.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RMIServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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() { + 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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/java/org/apache/tuscany/sca/binding/rmi/provider/RemoteInterfaceGenerator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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> remoteInterfaces = + Collections.synchronizedMap(new WeakHashMap, Class>()); + + 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 generate(Class javaInterface) { + if (!Remote.class.isAssignableFrom(javaInterface)) { + Class 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)javaInterface; + remoteInterfaces.put(javaInterface, remote); + } + return remote; + } else { + return (Class)javaInterface; + } + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..b188c24a20 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.rmi.provider.RMIBindingProviderFactory;model=org.apache.tuscany.sca.binding.rmi.RMIBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloException.java new file mode 100644 index 0000000000..cbc860ecc6 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..cd7a0fd625 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiImpl.java new file mode 100644 index 0000000000..89ea795529 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldRmiService.java new file mode 100644 index 0000000000..461c176e1e --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..3b705d2c97 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/java/org/apache/tuscany/sca/binding/rmi/BindingTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType new file mode 100644 index 0000000000..6def6715fd --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldImpl.componentType @@ -0,0 +1,23 @@ + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType new file mode 100644 index 0000000000..5a68cdde8d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/HelloWorldRmiImpl.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite new file mode 100644 index 0000000000..06c1c5e9fc --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi-runtime/src/test/resources/RMIBindingTest.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi/LICENSE b/branches/sca-java-2.0-M4/modules/binding-rmi/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-rmi/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..fe6b9f83f1 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +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: 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/branches/sca-java-2.0-M4/modules/binding-rmi/NOTICE b/branches/sca-java-2.0-M4/modules/binding-rmi/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/pom.xml b/branches/sca-java-2.0-M4/modules/binding-rmi/pom.xml new file mode 100644 index 0000000000..91c1d505cf --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi/pom.xml @@ -0,0 +1,41 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-rmi + Apache Tuscany SCA RMI Binding Model + + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java b/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java new file mode 100644 index 0000000000..36354ddc01 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBindingFactory.java new file mode 100644 index 0000000000..38445fa838 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory b/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory new file mode 100644 index 0000000000..889fcafae2 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.rmi.RMIBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for model factory +org.apache.tuscany.sca.binding.rmi.impl.RMIBindingFactoryImpl diff --git a/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-rmi/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..abc450f007 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-rmi/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.rmi,model=org.apache.tuscany.sca.binding.rmi.RMIBinding,factory=org.apache.tuscany.sca.binding.rmi.RMIBindingFactory diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..b26b8a0cbd --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/NOTICE new file mode 100644 index 0000000000..fdfa0e9faa --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/pom.xml new file mode 100644 index 0000000000..2a310c93a0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/pom.xml @@ -0,0 +1,103 @@ + + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-sca-axis2-runtime + Apache Tuscany SCA Axis2-based Default Binding Extension + + + + + org.apache.tuscany.sca + tuscany-binding-sca-runtime + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-wsdlgen + 2.0-M4-SNAPSHOT + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 2.0-M4-SNAPSHOT + test + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCABindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return DistributedSCABinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..97b9b2fa90 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.sca.axis2.impl.Axis2SCABindingProviderFactory;model=org.apache.tuscany.sca.assembly.DistributedSCABinding diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/AsynchTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/CallbackTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/PromotionTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/SimpleTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldCallbackRemote.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackOnewayRemote.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceCallbackRemote.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceLocal.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/HelloWorldServiceRemote2.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackOnewayRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientCallbackRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientLocalImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemote2Impl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldClientRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackOnewayRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceCallbackRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceLocalImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceMultipleServicesImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/java/org/apache/tuscany/sca/binding/sca/axis2/helloworld/impl/HelloWorldServiceRemoteImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite new file mode 100644 index 0000000000..385c456ddf --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/HelloWorld.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchReference/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite new file mode 100644 index 0000000000..bab26454ba --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/HelloWorld.composite @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/asynchService/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite new file mode 100644 index 0000000000..f02c77a01e --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/HelloWorld.composite @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d7685c6143 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackReference/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite new file mode 100644 index 0000000000..e0fae3c988 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/HelloWorld.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..d7685c6143 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/callbackService/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite new file mode 100644 index 0000000000..dece7b0d63 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite new file mode 100644 index 0000000000..4579442a99 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/HelloWorldComponent.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionReference/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite new file mode 100644 index 0000000000..00ac746111 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorld.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite new file mode 100644 index 0000000000..944dd0b625 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/HelloWorldComponent.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/promotionService/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite new file mode 100644 index 0000000000..87945b6692 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/HelloWorld.composite @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleReference/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite new file mode 100644 index 0000000000..f94b6d3ba0 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/HelloWorld.composite @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..00afc5b7f4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-axis2-runtime/src/test/resources/simpleService/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/LICENSE b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..159e362c07 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/NOTICE b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/pom.xml b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/pom.xml new file mode 100644 index 0000000000..5a7bd67904 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/pom.xml @@ -0,0 +1,72 @@ + + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-sca-runtime + Apache Tuscany SCA Binding SCA Model + + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCABindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 getModelType() { + return SCABinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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)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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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)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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..9986f45062 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..6b2ddd8600 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.sca.provider.RuntimeSCABindingProviderFactory;model=org.apache.tuscany.sca.assembly.SCABinding diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/main/resources/org/apache/tuscany/sca/binding/sca/definitions.xml @@ -0,0 +1,26 @@ + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/SCABindingTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/ReadTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/java/org/apace/tuscany/sca/binding/sca/xml/WriteTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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("", + 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("", + bos.toString()); + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/Calculator.composite b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/Calculator.composite new file mode 100644 index 0000000000..c404b3bcd4 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/Calculator.composite @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType new file mode 100644 index 0000000000..85535842be --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-sca-runtime/src/test/resources/CalculatorServiceImpl.componentType @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..992af5dd44 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/pom.xml new file mode 100644 index 0000000000..26104bdf23 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/pom.xml @@ -0,0 +1,139 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-ws-axis2-policy + Apache Tuscany SCA Policy Model for Axis2 WS binding + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy-security + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-axiom + 2.0-M4-SNAPSHOT + + + + org.apache.ws.commons.axiom + axiom-api + + + xerces + xercesImpl + + + javax.mail + mail + + + commons-logging + commons-logging + + + xml-apis + xml-apis + + + 1.2.7 + + + + org.apache.ws.commons.axiom + axiom-impl + 1.2.7 + + + + org.apache.axis2 + axis2-kernel + 1.4.1 + + + backport-util-concurrent + backport-util-concurrent + + + xalan + xalan + + + xerces + xercesImpl + + + xerces + xmlParserAPIs + + + org.apache.axis2 + axis2-adb + + + + + + backport-util-concurrent + backport-util-concurrent + 3.1 + test + + + + org.apache.neethi + neethi + 2.0.4 + + + wsdl4j + wsdl4j + + + org.codehaus.woodstox + wstx-asl + + + + + + commons-logging + commons-logging + 1.1.1 + runtime + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicy.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Axis2TokenAuthenticationPolicy.class; + } + + public void resolve(Axis2TokenAuthenticationPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationPolicyProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Axis2TokenAuthenticationPolicy.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationReferencePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/authentication/token/Axis2TokenAuthenticationServicePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicy.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 paramElements = new Hashtable(); + + public Map getParamElements() { + return paramElements; + } + + public QName getSchemaName() { + return NAME; + } + + public boolean isUnresolved() { + return false; + } + + public void setUnresolved(boolean unresolved) { + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/Axis2ConfigParamPolicyProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicy.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Axis2HeaderPolicy.class; + } + + public void resolve(Axis2HeaderPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return Axis2HeaderPolicy.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderPolicyUtil.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderReferencePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyInterceptor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2HeaderServicePolicyProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeader.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/header/Axis2SOAPHeaderString.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..8dd9f200d8 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory b/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.PolicyProviderFactory new file mode 100644 index 0000000000..ced48cf236 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/PolicyReadTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2-policy/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/policy/configuration/mock_policies.xml @@ -0,0 +1,36 @@ + + + + + + Timestamp Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties + + + + + Timestamp Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.IntegrityPWCBHandler" + + DirectReference + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..ae68eec237 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/pom.xml new file mode 100644 index 0000000000..94bc7f5c40 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/pom.xml @@ -0,0 +1,422 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + + tuscany-binding-ws-axis2 + Apache Tuscany SCA Axis2-based WS Binding Extension + + + + apache.ws + Apache WebServices Repository + http://ws.zones.apache.org/repository/ + legacy + + + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-wsdlgen + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-databinding + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-databinding-axiom + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-databinding-jaxb-axiom + 2.0-M4-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-http + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2-policy + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-policy-xml-ws + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-xsd + 2.0-M4-SNAPSHOT + + + + org.apache.axis2 + axis2-kernel + 1.4.1 + + + xerces + xmlParserAPIs + + + org.apache.axis2 + axis2-adb + + + org.apache.ant + ant + + + org.apache.ant + ant-launcher + + + + + + org.apache.axis2 + axis2-java2wsdl + 1.4.1 + + + org.apache.ant + ant + + + org.apache.ant + ant-launcher + + + xom + xom + + + + + + org.apache.axis2 + axis2-codegen + 1.4.1 + runtime + + + org.apache.axis2 + axis2-adb + + + stax + stax-api + + + + + + org.apache.neethi + neethi + 2.0.4 + + + org.codehaus.woodstox + wstx-asl + + + + + + commons-httpclient + commons-httpclient + 3.1 + + + + org.apache.httpcomponents + httpcore + 4.0.1 + + + + org.apache.httpcomponents + httpcore-nio + 4.0.1 + + + + commons-logging + commons-logging + 1.1.1 + + + + commons-collections + commons-collections + 3.2 + + + + commons-discovery + commons-discovery + 0.4 + + + + org.apache.axis2 + axis2-mtompolicy + 1.4.1 + + + + org.apache.santuario + xmlsec + 1.4.2 + + + + org.apache.ws.security + wss4j + 1.5.4 + + + bouncycastle + bcprov-jdk13 + + + bouncycastle + bcprov-jdk15 + + + junit + junit + + + xml-apis + xml-apis + + + + + + org.apache.axis2 + mex + 1.41 + impl + + + + org.apache.rampart + rampart-core + 1.4 + + + org.apache.ant + ant-nodeps + + + org.apache.axis2 + addressing + + + org.apache.axis2 + axis2-xmlbeans + + + org.apache.axis2 + mex + + + org.apache.axis2 + axis2-adb + + + org.apache.axis2 + axis2-codegen + + + org.apache.axis2 + axis2-adb-codegen + + + xmlbeans + xbean + + + org.apache.ws.commons.schema + XmlSchema + + + stax + stax-api + + + bouncycastle + bcprov-jdk13 + + + bouncycastle + bcprov-jdk15 + + + junit + junit + + + xml-apis + xml-apis + + + + + + javax.servlet + servlet-api + 2.5 + provided + + + + + xalan + xalan + 2.7.0 + optional + + + xml-apis + xml-apis + + + + + + xerces + xercesImpl + 2.8.1 + + + xml-apis + xml-apis + + + + + + + org.apache.tuscany.sca + tuscany-host-jetty + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M4-SNAPSHOT + test + + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + 1.1 + provided + + + org.apache.geronimo.specs + geronimo-jms_1.1_spec + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 axis2HeaderPolicies = new ArrayList(); + + 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 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() { + 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() { + 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2BindingProviderFactory.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + private FactoryExtensionPoint modelFactories; + private ServletHost servletHost; + private DataBindingExtensionPoint dataBindings; + + public Axis2BindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ServletHostExtensionPoint servletHosts = extensionPoints.getExtensionPoint(ServletHostExtensionPoint.class); + List 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 getModelType() { + return WebServiceBinding.class; + } +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ConfiguratorHelper.java new file mode 100644 index 0000000000..782cfd6066 --- /dev/null +++ b/branches/sca-java-2.0-M4/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.ServiceDiscovery; +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() { + 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 = ServiceDiscovery.getInstance().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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2OneWayBindingInvoker.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceBindingProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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 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 imports = (List)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() { + 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 getExtensibilityElement(List elements, Class 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() { + 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 policyProviders = ((RuntimeComponentReference)contract).getPolicyProviders(wsBinding); + + for (PolicyProvider policyProvider : policyProviders){ + policyHandler = policyProvider.createHandler(); + if (policyHandler != null) { + policyHandlerList.add(policyHandler); + } + } +*/ + } + } + + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInMessageReceiver.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceInOutSyncMessageReceiver.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceProvider.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 urlMap = new HashMap(); + + private BasicAuthenticationPolicy basicAuthenticationPolicy = null; + private Axis2TokenAuthenticationPolicy axis2TokenAuthenticationPolicy = null; + private List axis2HeaderPolicies = new ArrayList(); + + 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 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 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 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 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 imports = (List)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() { + 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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceServlet.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/AxisPolicyHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyAxisConfigurator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + *

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() { + 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() { + 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() { + 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyDispatcher.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/ + * + * @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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListenerManager.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java new file mode 100644 index 0000000000..3f8599b118 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/TuscanyListingAgent.java @@ -0,0 +1,218 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sca.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); + 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 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingBasicAuthenticationConfigurator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 auth = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/sca/binding/ws/axis2/policy/configurator/Axis2BindingHeaderConfigurator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.definitions.xml.Definitions new file mode 100644 index 0000000000..91a24cc1b4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..a48ff54c77 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +org.apache.tuscany.sca.binding.ws.axis2.Axis2BindingProviderFactory;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/definitions.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + Communication through this binding requires MTOM support + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/axis2.xml @@ -0,0 +1,504 @@ + + + + + + + + true + false + false + false + + + + + + + + + 30000 + + + + + + true + + + + + + false + + admin + axis2 + + + + + + + + + + + + + + + + + + + + + + + + / + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 6060 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + + HTTP/1.1 + chunked + + + + + + + HTTP/1.1 + chunked + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/modules.list b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar b/branches/sca-java-2.0-M4/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 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/modules/rampart-1.4.mar differ diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/main/resources/org/apache/tuscany/sca/binding/ws/axis2/engine/config/services/services.list b/branches/sca-java-2.0-M4/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 diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ReferenceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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("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 callbackOp = +// new Operation("sayHiCallback", null, null, null, true, null, NO_CONVERSATION); +// HashMap> callbackOps = new HashMap>(); +// callbackOps.put("sayHiCallback", callbackOp); +// contract.setCallbackOperations(callbackOps); +// EasyMock.expect(inboundWire.getTargetContract()).andReturn(contract).anyTimes(); +// EasyMock.replay(inboundWire); +// +// axis2Reference.setWire(inboundWire); +// Operation operation = new Operation("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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Axis2ServiceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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> opMap = new HashMap>(); +// for (Method m : Greeter.class.getMethods()) { +// opMap.put(m.getName(), new Operation(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, InvocationChain> map = new HashMap, 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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/Greeter.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/GreetingCallback.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Account.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/AccountService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Bar.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/CustomerProfileData.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Echo.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoComponent.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/EchoImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/Foo.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldComponent.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldMultiService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDLTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOM2.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMComponent.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldOMTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldWSDLMergedTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/UriPrecedenceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/AbstractHelloWorldOMTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiServiceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleServiceTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURITestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURITestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorldTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/Data2.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/POJOWSTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestService.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/TestServiceImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/package-info.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/AbstractHelloWorldOMTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ClientPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/IntegrityPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/ServerPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthenticationTestCaseFIXME.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrityTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/AbstractHelloWorldOMTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ClientPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/IntegrityPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/ServerPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixedTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/AbstractHelloWorldOMTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ClientPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/IntegrityPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/ServerPWCBHandler.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthenticationTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentialityTestCaseFIXBouncyCastleIssue.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrityTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12TestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCaseOFF.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/META-INF/services/org.apache.tuscany.sca.policy.util.PolicyHandler b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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=;model= +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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorld.composite @@ -0,0 +1,47 @@ + + + + + + + + + + + http://localhost:8085/services/HelloWorldWebService + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/HelloWorldNoWSDL.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdata.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerdefs.xsd @@ -0,0 +1,27 @@ + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/customerinfo.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultMultiService.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/DefaultSingleService.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLExplicitURI.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/WSDLRelativeURI.composite @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/endpoints/helloworld-om-relative-uri.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/epr/HelloWorld.composite @@ -0,0 +1,48 @@ + + + + + + + + + + + http://localhost:8085/myService + + + + + + + + + + + http://localhost:8085/myService + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-binding.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-merged.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-porttype.wsdl @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om-uri.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-om.wsdl @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.composite @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld-prec.wsdl @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/helloworld.wsdl @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.compositeOFF @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/pojo/test.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityAuthentication.composite.OFF @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityConfidentiality.composite.OFF @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/WSSecurityIntegrity.composite.OFF @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/definitions.xml @@ -0,0 +1,101 @@ + + + + + + + + + + UsernameToken + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ServerPWCBHandler + + + + + + + + + + UsernameToken + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.ClientPWCBHandler" + + PasswordText + + + + + + + + + + Timestamp Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + + + + + Timestamp Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler" + + DirectReference + + + + + + + + + + Timestamp Signature Encrypt + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + + + + + Timestamp Signature Encrypt + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.configparams.IntegrityPWCBHandler + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties + DirectReference + SKIKeyIdentifier + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/security.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks b/branches/sca-java-2.0-M4/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 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/configparams/tuscanyKeys.jks differ diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/intent/definitions.xml @@ -0,0 +1,32 @@ + + + + + + + Communitcation thro this binding required Authentication. + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/WSSecurityMixed.composite.OFF @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/definitions.xml @@ -0,0 +1,323 @@ + + + + + + + + + + UsernameToken + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + + + + + + UsernameToken + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler" + + PasswordText + + + + + + + + + + Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + + + + + + + + + + Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.IntegrityPWCBHandler + DirectReference + + + + + + + + + + UsernameToken Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + Signature + TuscanyWsUser + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + DirectReference + + + + + + + + + + Signature + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + + + + + UsernameToken Signature + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler" + + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties + PasswordText + DirectReference + + + + + + + + + + + + + + + + + TuscanyWsUser + + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ClientPWCBHandler + + + + + + + + + + + + + + + + + + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.mixed.ServerPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/security.properties b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks b/branches/sca-java-2.0-M4/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 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/mixed/tuscanyKeys.jks differ diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityAuthentication.composite.OFF @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityConfidentiality.composite.OFF @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/WSSecurityIntegrity.composite.OFF @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/definitions.xml @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + + + + TuscanyWsUser + PasswordText + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.ClientPWCBHandler + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + TuscanyWsUser + TuscanyWsUser + org.apache.tuscany.sca.binding.ws.axis2.itests.policy.wspolicy.IntegrityPWCBHandler + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + JKS + org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks + TuscanyWsUserPasswd + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks b/branches/sca-java-2.0-M4/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 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/policy/wspolicy/tuscanyKeys.jks differ diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import-nested.wsdl @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-import.wsdl @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-include.wsdl @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-import.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/HelloWorldSOAP12.composite.OFF @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/questionmark-wsdl.composite.OFF @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5d7c3a3457 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/pom.xml new file mode 100644 index 0000000000..8c2d305dc2 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-ws-wsdlgen + Apache Tuscany SCA Web Service binding WSDL Generator + + + + + org.apache.tuscany.sca + tuscany-binding-ws + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-interface-java + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-interface-java-jaxws + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-xsd + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding + 2.0-M4-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2-policy + 2.0-M4-SNAPSHOT + + + + junit + junit + 4.5 + test + + + org.apache.tuscany.sca + tuscany-core-databinding + 2.0-M4-SNAPSHOT + test + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGenerator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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> inputType, Map 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 helpers) { + if (getTypeHelper(outputType, helpers) != getTypeHelper(wrapperType, helpers)) { + return false; + } else { + return true; + } + } + + private void addDataType(Map> map, DataType type, Map 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 types = map.get(helper); + if (types == null) { + types = new ArrayList(); + map.put(helper, types); + } + types.add(type); + } + + private Map> getDataTypes(Interface intf, boolean useWrapper, Map helpers) { + Map> dataTypes = new HashMap>(); + 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 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(JAXBDataBinding.NAME, cls, XMLType.UNKNOWN); + addDataType(dataTypes, dt, helpers); + } + } + seeAlso = getSeeAlso(javaInterface.getCallbackClass()); + if (seeAlso != null) { + for (Class cls : seeAlso) { + DataType dt = new DataTypeImpl(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 helpers = new HashMap(); + Map> wrappers = new HashMap>(); + 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> en: getDataTypes(interfaze, false, helpers).entrySet()) { + XMLTypeHelper helper = en.getKey(); + if (helper == null) { + continue; + } + List 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(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 wrapperXSDs = new HashMap(); + Map> prefixMaps = new HashMap>(); + for (Map.Entry> 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()); + 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 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 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 helpers, + Map> 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 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 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 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 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(); + elements.add(getElementInfo(logical.getPhysical(), logical, null, helpers)); + } else { + // convert synthesized fault bean to a wrapper type + for (DataType propDT: op.getFaultBeans().get(faultName)) { + XMLType logical = propDT.getLogical(); + elements = new ArrayList(); + 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 helpers, + Map> 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 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 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 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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLDefinitionGenerator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLGenerationException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WSDLServiceGenerator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 ports = new ArrayList(); + 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 imports = new ArrayList(); + 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 imports) { + return addImport(portType.getQName(), PortType.class, wsdlDef, newDef, imports); + } + + private static boolean importBinding(Binding binding, + WSDLDefinition wsdlDef, + Definition newDef, + List 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 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 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) { + // 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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 { + + 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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder new file mode 100644 index 0000000000..e7194dc72d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder @@ -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.wsdlgen.WebServiceBindingBuilder;qname=http://docs.oasis-open.org/ns/opencsa/sca/200903#binding.ws diff --git a/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/main/resources/wsdlgen-validation-messages.properties new file mode 100644 index 0000000000..a94c1d9bef --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/Other.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/other/package-info.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGeneratorTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/Interface2WSDLGeneratorTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestException.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFault.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestFaultBean.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaClass.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws-wsdlgen/src/test/java/org/apache/tuscany/sca/binding/ws/wsdlgen/TestJavaInterface.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/LICENSE b/branches/sca-java-2.0-M4/modules/binding-ws/LICENSE new file mode 100644 index 0000000000..8aa906c321 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/binding-ws/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7546d43106 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/NOTICE b/branches/sca-java-2.0-M4/modules/binding-ws/NOTICE new file mode 100644 index 0000000000..25bb89c9b2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/pom.xml b/branches/sca-java-2.0-M4/modules/binding-ws/pom.xml new file mode 100644 index 0000000000..221a4294d2 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws/pom.xml @@ -0,0 +1,95 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-binding-ws + Apache Tuscany SCA WS Binding Model + + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-wsdl + 2.0-M4-SNAPSHOT + + + + wsdl4j + wsdl4j + 1.6.2 + + + + org.apache.tuscany.sca + tuscany-builder + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-core + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-binding-sca-runtime + 2.0-M4-SNAPSHOT + test + + + + + + + + apache.ws.zone + Apache WS Zone Repository + http://ws.zones.apache.org/repository2 + + true + + + false + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java new file mode 100644 index 0000000000..5e0f8a0a88 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java b/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBindingFactory.java new file mode 100644 index 0000000000..1ad38c69e4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/addressing/EndPointReference.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + * <wsa:EndpointReference> + * <wsa:Address>xs:anyURI</wsa:Address> + * <wsa:ReferenceProperties>... </wsa:ReferenceProperties> ? + * <wsa:ReferenceParameters>... </wsa:ReferenceParameters> ? + * <wsa:PortType>xs:QName</wsa:PortType> ? + * <wsa:ServiceName PortName="xs:NCName"?>xs:QName</wsa:ServiceName> ? + * <wsp:Policy> ... </wsp:Policy>* + * </wsa:EndpointReference> + * @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 getReferenceProperties(); + + List getReferenceParameters(); + + List getPolicies(); + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingFactoryImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 extensions = new ArrayList(); + private List attributeExtensions = new ArrayList(); + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + 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 getExtensions() { + return extensions; + } + + public List 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 getPolicySets() { + return policySets; + } + + public List 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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/EndPointReferenceHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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, 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 + 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 + 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 = 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 = 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 getModelType() { + return WebServiceBinding.class; + } + +} diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceConstants.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory b/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.binding.ws.WebServiceBindingFactory new file mode 100644 index 0000000000..6d50a24b93 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..351e436807 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/binding-ws/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.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/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties b/branches/sca-java-2.0-M4/modules/binding-ws/src/main/resources/binding-wsxml-validation-messages.properties new file mode 100644 index 0000000000..2dfa5e6133 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/ReadTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/java/org/apache/tuscany/sca/binding/ws/xml/WriteTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator-bad-wsdlElement.composite @@ -0,0 +1,59 @@ + + + + + + + + + http://localhost:8085/Calculator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/Calculator.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + http://localhost:8085/services/HelloWorldWebService + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/CalculatorImpl.componentType @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + myURI + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/PoliciedCalculator.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/example.wsdl @@ -0,0 +1,26 @@ + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/invalid-stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/ipo.xsd @@ -0,0 +1,136 @@ + + + + + + International Purchase order schema for Example.com + Copyright 2000 Example.com. All rights reserved. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/stockquote.wsdl @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.wsdl @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test1.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/test2.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/binding-ws/src/test/resources/org/apache/tuscany/sca/binding/ws/xml/unwrapped-stockquote.wsdl @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/builder/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/builder/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..df432f10c2 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/pom.xml b/branches/sca-java-2.0-M4/modules/builder/pom.xml new file mode 100644 index 0000000000..752abf85d3 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-builder + Apache Tuscany SCA Model Builders + + + + + org.apache.tuscany.sca + tuscany-assembly + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-assembly-xml + 2.0-M4-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-contribution + 2.0-M4-SNAPSHOT + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BaseBuilderImpl.java new file mode 100644 index 0000000000..111680b2b4 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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 components, + Map componentServices, + Map 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 componentServices, + Map componentReferences, + Map 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 services, + Map references, + Map 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 properties, + Map 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 references, + Map 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 services, + Map 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/BindingURIBuilderImpl.java new file mode 100644 index 0000000000..205a3157de --- /dev/null +++ b/branches/sca-java-2.0-M4/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> 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 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> 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> 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> 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 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java new file mode 100644 index 0000000000..431d21179c --- /dev/null +++ b/branches/sca-java-2.0-M4/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) { + // $/... + 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 element + Node property = node.getDocumentElement(); + // The first child of the element is a 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 element, use it directly in the result + newProperty.appendChild(document.importNode(result, true)); + } else { + // If the result is not a element, create a 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferenceBindingBuilderImpl.java new file mode 100644 index 0000000000..c48d868105 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentReferencePromotionBuilderImpl.java new file mode 100644 index 0000000000..aaa9cbe82c --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentServiceBindingBuilderImpl.java new file mode 100644 index 0000000000..9a74023504 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeCloneBuilderImpl.java new file mode 100644 index 0000000000..148a3b5368 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 includes = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeComponentTypeBuilderImpl.java new file mode 100644 index 0000000000..75fda5880a --- /dev/null +++ b/branches/sca-java-2.0-M4/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 components = new HashMap(); + Map componentServices = new HashMap(); + Map componentReferences = new HashMap(); + 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 components, + Map componentServices, + Map 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 components, + Map 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 components, + Map 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 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 components, + Map 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 components, + Map 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 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositeIncludeBuilderImpl.java new file mode 100644 index 0000000000..b4a897af54 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/CompositePolicyBuilderImpl.java new file mode 100644 index 0000000000..f36a702752 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 intents = new HashSet(); + 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 copy = new HashSet(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 copy = new HashSet(intents); + for (Intent i : copy) { + if (i.getQualifiableIntent() != null) { + intents.remove(i.getQualifiableIntent()); + } + } + + // Replace qualifiable intents with the default qualified intent + copy = new HashSet(intents); + for (Intent i : copy) { + if (i.getDefaultQualifiedIntent() != null) { + intents.remove(i); + intents.add(i.getDefaultQualifiedIntent()); + } + } + + subject.getRequiredIntents().clear(); + subject.getRequiredIntents().addAll(intents); + + Set policySets = new HashSet(); + 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 getPolicyNames(PolicySubject subject) { + if (subject == null) { + return Collections.emptySet(); + } + Set names = new HashSet(); + 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointBuilderImpl.java new file mode 100644 index 0000000000..6b181db0c1 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 asyncOperations = null; + try { + asyncOperations = (List) 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java new file mode 100644 index 0000000000..b1cc873914 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 components = new HashMap(); + Map componentServices = new HashMap(); + Map componentReferences = new HashMap(); + 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 components, + Map componentServices, + Map 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 componentServices, + Map 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 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 components, + Map componentServices, + Monitor monitor) { + + monitor.pushContext("Reference: " + reference.getName()); + + // Get reference targets + List 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()) { + // getReferenceTargets(ComponentReference reference) { + List 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 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 + *
    + *
  • componentName + *
  • componentName/serviceName + *
  • componentName/serviceName/bindingName + *
+ * @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) { + // #service-binding(serviceName/bindingName) + uri = uri + "#service-binding(" + parts[1] + "/" + parts[2] + ")"; + } else if (parts.length == 2) { + // #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 of a has @autowire=true + * and where the has a child element which + * declares a single target service, the reference is wired only to + * the single service identified by the 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ModelBuilderImpl.java new file mode 100644 index 0000000000..206afb98da --- /dev/null +++ b/branches/sca-java-2.0-M4/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 compositeProcessor = + xmlProcessors.getProcessor(Composite.class); + + return writeComposite(composite, compositeProcessor); + } + + private String writeComposite(Composite composite, StAXArtifactProcessor 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\n" + + writeComposite((Composite)component.getImplementation(), + compositeProcessor); + } + } + + return result; + } +} diff --git a/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java new file mode 100644 index 0000000000..cbbf54b330 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 + 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 applicableNodes = null; + /* + XPathExpression appliesTo = ps.getAppliesToXPathExpression(); + if (appliesTo != null) { + applicableNodes = new HashSet(); + 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ReferenceConfigurationUtil.java new file mode 100644 index 0000000000..67b143e95d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 getPromotedComponentReferences(CompositeReference compositeReference) { + List componentReferences = new ArrayList(); + 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 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 callbackBindings = new HashSet(); + 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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ServiceConfigurationUtil.java new file mode 100644 index 0000000000..ef03344131 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java b/branches/sca-java-2.0-M4/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/StructuralURIBuilderImpl.java new file mode 100644 index 0000000000..b543e3347d --- /dev/null +++ b/branches/sca-java-2.0-M4/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 bindings = contract.getBindings(); + Map bindingMap = new HashMap(); + 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> 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/branches/sca-java-2.0-M4/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder b/branches/sca-java-2.0-M4/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder new file mode 100644 index 0000000000..5de5512c82 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.CompositeBuilder @@ -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.builder.impl.ModelBuilderImpl;id=org.apache.tuscany.sca.assembly.builder.CompositeBuilder diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java b/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/BuildPolicyTestCase.java new file mode 100644 index 0000000000..0c7105bd9f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 documentProcessor; + private static URLArtifactProcessor 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 policyDefinitions = new ArrayList(); + 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/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java b/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/CompositeBuilderTestCase.java new file mode 100644 index 0000000000..a99d0df91c --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java b/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/MockPolicy.java new file mode 100644 index 0000000000..dac50ec227 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java b/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentTestCase.java new file mode 100644 index 0000000000..9102257b77 --- /dev/null +++ b/branches/sca-java-2.0-M4/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 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 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/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java b/branches/sca-java-2.0-M4/modules/builder/src/test/java/org/apache/tuscany/sca/builder/impl/TestPolicyProcessor.java new file mode 100644 index 0000000000..1201b6e36f --- /dev/null +++ b/branches/sca-java-2.0-M4/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 { + 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 getModelType() { + return MockPolicy.class; + } + + public void resolve(MockPolicy arg0, ModelResolver arg1, ProcessorContext context) throws ContributionResolveException { + + } + +} diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite new file mode 100644 index 0000000000..d6082a936d --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite new file mode 100644 index 0000000000..105a478842 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite1.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite new file mode 100644 index 0000000000..d3d5bafdfc --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite2.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite new file mode 100644 index 0000000000..12aa35b694 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite3.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite new file mode 100644 index 0000000000..141ff2a4ea --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/Composite4.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml new file mode 100644 index 0000000000..fe76d0038a --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/definitions.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg new file mode 100644 index 0000000000..a010bb1bf1 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.odg differ diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png new file mode 100644 index 0000000000..e1f78f6423 Binary files /dev/null and b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/scenario.png differ diff --git a/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml new file mode 100644 index 0000000000..dac8e384e3 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/builder/src/test/resources/org/apache/tuscany/sca/builder/impl/test_definitions.xml @@ -0,0 +1,207 @@ + + + + + + + + + + + + Test Intent + + + + + + Protect messages from unauthorized reading or modification + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + ... + + + + + + + + + + + sp:X509v3 + + + + + + + + + + + + + + + + + + Protect messages from unauthorized reading or modification + + + + + + Protect messages from unauthorized reading or modification + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + + + + + + Communitcation thro this binding must prevent + unauthorized modification of the messages. + + + + + + Communitcation thro this binding required + Authentication. + + + + + + All messages to and from this implementation must be logged + + + + + + Need to figure out some description for this + + + + \ No newline at end of file diff --git a/branches/sca-java-2.0-M4/modules/common-java/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/common-java/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..1795f1eacf --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-java/pom.xml b/branches/sca-java-2.0-M4/modules/common-java/pom.xml new file mode 100644 index 0000000000..270dbeed4f --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/common-java/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-common-java + Apache Tuscany SCA Common Java + + + + org.apache.tuscany.sca + tuscany-extensibility + 2.0-M4-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M4-SNAPSHOT + + + + + + + jdk15 + + 1.5 + + + + + diff --git a/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/classloader/ClassLoaderDelegate.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 classLoaders = new ArrayList(); + + /** + * @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 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 findResources(String resName) throws IOException { + Enumeration[] enums = new Enumeration[classLoaders.size()]; + int index = 0; + for (ClassLoader parent : classLoaders) { + enums[index++] = parent.getResources(resName); + } + return new CompoundEnumeration(enums); + } +} diff --git a/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CollectionMap.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 extends ConcurrentHashMap> { + private static final long serialVersionUID = -8926174610229029369L; + + public boolean putValue(K key, V value) { + Collection collection = get(key); + if (collection == null) { + collection = createCollection(); + put(key, collection); + } + return collection.add(value); + } + + public boolean putValues(K key, Collection value) { + Collection collection = get(key); + if (collection == null) { + collection = createCollection(); + put(key, collection); + } + return collection.addAll(value); + } + + public boolean removeValue(K key, V value) { + Collection collection = get(key); + if (collection == null) { + return false; + } + return collection.remove(value); + } + + protected Collection createCollection() { + return new ArrayList(); + } + +} diff --git a/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundEnumeration.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 implements Enumeration { + private Enumeration[] enumerations = null; + private int index = 0; + + public CompoundEnumeration(Enumeration... 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 findNextEnumeration(boolean moveCursor) { + return findNextEnumeration(index, moveCursor); + } + + private Enumeration 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 currentEnumeration() { + if (enumerations != null) { + if (index < enumerations.length) { + Enumeration 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/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/CompoundIterator.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 implements Iterator { + private Iterator[] iterators = null; + private int index = 0; + + public CompoundIterator(Iterator... iterators) { + this.iterators = iterators; + } + + @SuppressWarnings("unchecked") + public CompoundIterator(Collection... 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 findNextIterator(boolean moveCursor) { + return findNextIterator(index, moveCursor); + } + + private Iterator 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 currentIterator() { + if (iterators != null) { + if (index < iterators.length) { + Iterator 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/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/collection/LRUCache.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 + * @param + */ + +public class LRUCache extends LinkedHashMap { + 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 LRUCache 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 - true for access-order, + * false 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 eldest) { + return size() > maxCacheSize; + } +} diff --git a/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/io/IOHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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: 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/branches/sca-java-2.0-M4/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 getAllFields(Class clazz, Set 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() { + public Object run() { + field.setAccessible(true); // ignore Java accessibility + return null; + } + }); + fields.add(field); + } + } + return fields; + } + + /** + * @param cls + * @return + */ + public Set getAllNonStaticOrFinalFields(Class cls) { + Set fields = new HashSet(); + return getAllFields(cls, fields, -1, Modifier.STATIC | Modifier.FINAL); + } + + /** + * @param cls + * @return + */ + public Set getAllNonStaticMethods(Class cls) { + Set methods = new HashSet(); + return getAllUniqueMethods(cls, methods, -1, Modifier.STATIC); + } + + /** + * Recursively evaluates the type hierarchy to return all unique methods + */ + private static Set getAllUniqueMethods(Class pClass, Set 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 temp = new ArrayList(); + 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() { + 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 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 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 Constructor getDefaultConstructor(Class 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 + * foo is returned as getFoo + */ + 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, setFoo(var) + * is returned as property foo + */ + 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 + 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 + 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 + 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 + * foo is returned as setFoo(var) + */ + 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: + * JavaIntrospectionHelper.getGenerics(field.getGenericType()); + *

+ * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); + * + * @return the generic types in order of declaration or an empty array if + * the type is not genericized + */ + public static List getGenerics(Type genericType) { + List classes = new ArrayList(); + 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:

public class Foo{ //.. } + *

+ * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); + *

+ * 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> getAllInterfaces(Class clazz) { + Set> implemented = new HashSet>(); + getAllInterfaces(clazz, implemented); + return implemented; + } + + private static void getAllInterfaces(Class clazz, Set> 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, String> signatures = new HashMap, 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/branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 methods = helper.getAllNonStaticMethods(SubTestImpl.class); + System.out.println(methods); + } + + @Test + public void testGetFields() { + Set fields = helper.getAllNonStaticOrFinalFields(SubTestImpl.class); + System.out.println(fields); + } + + @Test + public void testGetAllInterfaces() { + Set> 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/branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/SubTestImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test1.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/Test2.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/TestImpl.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-xml/META-INF/MANIFEST.MF b/branches/sca-java-2.0-M4/modules/common-xml/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..1a40ccd3b9 --- /dev/null +++ b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-xml/pom.xml b/branches/sca-java-2.0-M4/modules/common-xml/pom.xml new file mode 100644 index 0000000000..8276925a96 --- /dev/null +++ b/branches/sca-java-2.0-M4/modules/common-xml/pom.xml @@ -0,0 +1,98 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-modules + 2.0-M4-SNAPSHOT + ../pom.xml + + tuscany-common-xml + Apache Tuscany SCA Common XML + + + + org.apache.tuscany.sca + tuscany-extensibility + 2.0-M4-SNAPSHOT + + + + xmlunit + xmlunit + 1.2 + test + + + + + + + jdk15 + + 1.5 + + + + + org.apache.geronimo.specs + geronimo-stax-api_1.0_spec + 1.0.1 + + + + org.codehaus.woodstox + wstx-asl + 3.2.4 + runtime + + + stax + stax-api + + + + + + javax.xml.bind + jaxb-api + 2.1 + + + javax.xml.stream + stax-api + + + + + + com.sun.xml.bind + jaxb-impl + 2.1.12 + runtime + + + + + + + + diff --git a/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java b/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/XMLDocumentHelper.java new file mode 100644 index 0000000000..33a97f4342 --- /dev/null +++ b/branches/sca-java-2.0-M4/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(""); + 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/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/DOMHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/dom/impl/SAX2DOMAdapter.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 nodeStk = new Stack(); + + private List 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(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/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/sax/SAXHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/StAXHelper.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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 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 getAttributeAsQNames(XMLStreamReader reader, String name) { + String value = reader.getAttributeValue(null, name); + if (value != null) { + List qnames = new ArrayList(); + 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 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 values = new ArrayList(); + + /** + * @param element + * @param name + */ + public Attribute(QName element, String name) { + super(); + this.element = element; + this.name = name; + } + + public List 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/branches/sca-java-2.0-M4/modules/common-xml/src/main/java/org/apache/tuscany/sca/common/xml/stax/impl/StAX2SAXAdapter.java b/branches/sca-java-2.0-M4/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/branches/sca-java-2.0-M4/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: + *