From 60d2a1e4f280c97b4de5b81b6e40f29749b86b4f Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 6 Apr 2009 07:32:56 +0000 Subject: Tag 2.0 M2 RC2 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@762237 13f79535-47bb-0310-9956-ffa450edef68 --- tags/java/sca/2.0-M2/samples/README | 232 ++++++++++++ .../2.0-M2/samples/binding-ws-calculator/README | 97 +++++ .../2.0-M2/samples/binding-ws-calculator/build.xml | 67 ++++ .../samples/binding-ws-calculator/calculator.png | Bin 0 -> 20552 bytes .../samples/binding-ws-calculator/calculator.svg | 329 ++++++++++++++++ .../2.0-M2/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 | 42 +++ .../src/main/resources/Calculator.composite | 59 +++ .../main/resources/META-INF/sca-contribution.xml | 23 ++ .../test/java/calculator/CalculatorTestCase.java | 41 ++ tags/java/sca/2.0-M2/samples/build-common.xml | 102 +++++ .../sca/2.0-M2/samples/calculator-equinox/README | 97 +++++ .../2.0-M2/samples/calculator-equinox/build.xml | 78 ++++ .../samples/calculator-equinox/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator-equinox/calculator.svg | 329 ++++++++++++++++ .../sca/2.0-M2/samples/calculator-equinox/pom.xml | 91 +++++ .../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 + .../java/sca/2.0-M2/samples/calculator-osgi/README | 97 +++++ .../sca/2.0-M2/samples/calculator-osgi/build.xml | 78 ++++ .../sca/2.0-M2/samples/calculator-osgi/pom.xml | 109 ++++++ .../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 +++ .../2.0-M2/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 +++ .../2.0-M2/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 +++++++++++++++++ .../2.0-M2/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 ++++ tags/java/sca/2.0-M2/samples/calculator/README | 97 +++++ tags/java/sca/2.0-M2/samples/calculator/build.xml | 65 ++++ .../sca/2.0-M2/samples/calculator/calculator.png | Bin 0 -> 20552 bytes .../sca/2.0-M2/samples/calculator/calculator.svg | 329 ++++++++++++++++ tags/java/sca/2.0-M2/samples/calculator/pom.xml | 78 ++++ .../src/main/java/calculator/AddService.java | 28 ++ .../src/main/java/calculator/AddServiceImpl.java | 35 ++ .../src/main/java/calculator/CalculatorClient.java | 48 +++ .../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 | 49 +++ .../main/resources/META-INF/sca-contribution.xml | 23 ++ .../test/java/calculator/CalculatorTestCase.java | 66 ++++ .../java/sca/2.0-M2/samples/helloworld-bpel/README | 151 ++++++++ .../sca/2.0-M2/samples/helloworld-bpel/build.xml | 95 +++++ .../samples/helloworld-bpel/helloworld-bpel.png | Bin 0 -> 8897 bytes .../samples/helloworld-bpel/helloworld-bpel.svg | 179 +++++++++ .../sca/2.0-M2/samples/helloworld-bpel/pom.xml | 198 ++++++++++ .../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 | 66 ++++ .../src/main/resources/helloworld.composite | 33 ++ .../src/main/resources/helloworld.wsdl | 82 ++++ .../src/main/resources/log4j.properties | 35 ++ .../helloworld/BPELHelloWorldTestCase.java.FIXME | 62 ++++ .../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 ++++ tags/java/sca/2.0-M2/samples/logging.properties | 25 ++ tags/java/sca/2.0-M2/samples/pom.xml | 64 ++++ .../2.0-M2/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 | 181 +++++++++ .../helloworld-jsf/src/main/webapp/helloWorld.jsp | 40 ++ .../helloworld-jsf/src/main/webapp/index.jsp | 23 ++ .../helloworld-jsf/src/main/webapp/page2.jsp | 38 ++ .../2.0-M2/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-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 +++ .../sca/2.0-M2/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 ++ 191 files changed, 11075 insertions(+) create mode 100644 tags/java/sca/2.0-M2/samples/README create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/README create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.png create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.svg create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/Calculator.composite create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/build-common.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/README create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.png create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.svg create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/resources/Calculator.composite create mode 100644 tags/java/sca/2.0-M2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/META-INF/MANIFEST.MF create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/README create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/resources/Calculator.composite create mode 100644 tags/java/sca/2.0-M2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/README create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.png create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.svg create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/README create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.png create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.svg create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/README create mode 100644 tags/java/sca/2.0-M2/samples/calculator/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator/calculator.png create mode 100644 tags/java/sca/2.0-M2/samples/calculator/calculator.svg create mode 100644 tags/java/sca/2.0-M2/samples/calculator/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/resources/Calculator.composite create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/2.0-M2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/README create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.png create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.svg create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.bpel create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.composite create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/log4j.properties create mode 100644 tags/java/sca/2.0-M2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java.FIXME create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/README create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/build.xml create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.png create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.svg create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/resources/Calculator.composite create mode 100644 tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 tags/java/sca/2.0-M2/samples/logging.properties create mode 100644 tags/java/sca/2.0-M2/samples/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/index.html create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld/pom.xml create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite create mode 100644 tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml (limited to 'tags/java/sca/2.0-M2/samples') diff --git a/tags/java/sca/2.0-M2/samples/README b/tags/java/sca/2.0-M2/samples/README new file mode 100644 index 0000000000..4ccefa3695 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/README @@ -0,0 +1,232 @@ +The Apache Tuscany SCA Samples +============================== +The Apache Tuscany SCA samples are built as part of the main Maven build and +run, using the provided JUnit test cases, as tests in the Maven build. + +In the binary distribution of Apache Tuscany most samples can also +be run using the provided Ant build.xml files. These show the samples running +from a simple main() method without the need for a JUnit test case. + +In these notes text that appears in angled brackets like this means +that you need to make a choice and provide your own text at that point. + +These simple samples have been created with the intention of illustrating the +usage of the SCA API and annotations and certainly not to levels of SCA component +abstraction. In real life situations you should use SCA to assemble real and +usually bigger components, and when you do that you'll get all the benefits of +SCA, bindings, policies, integration in an SOA environment etc.. + +Sample Overview +--------------- +The samples generally show off different features of the SCA runtime +and the extensions that come packaged with it. + +binding-ws-calculator - Calculator running inside a web app also + showing webservices binding + +calculator - Calculator built with java components and + local wires. + +calculator-equinox - Calculator running inside a Equinox OSGi runtime + +calculator-osgi - Calculator running inside a OSGi runtime + +calculator-rmi-reference - The calculator configured to talk RMI to + the calculator-rmi-service sample +calculator-rmi-service - The calculator configured to accept RMI + requests from calculator-rmi-reference + +implementation-java-calculator + + +Sample Layout +------------- +All sample directories are organized in the same way based on the default +project template provided by Maven. For example, take a look at the calculator +sample; + +calculator/ + src/ - Holds all of the source files for the sample + main/ - Groups together the files that implement the sample + java/ - Java source files + resources/ - Non java resource files such as composte files + test/ - Groups together files that provide sample tests + java - Java test sources files. Usually JUnit test cases + target/ - Holds the files generated when the sample is built + classes/ - For example, Java class files + test-classes/ - classes from src/test and other test files + +Getting Ready To Build +---------------------- +You will need to install the following software before you start. + +J2SE Development Kit (JDK) 5.0 +Apache Ant 1.7.1 - if you are going to use Ant +Apache Maven 2.0.9 - if you are going to use Maven + +Java and Ant and/or Maven binary directories must be present in your PATH so +that their executable programs are available in your environment. You may +find it useful to use a script to set up your environment, for example; + +For UNIX: + JAVA_HOME=/ + ANT_HOME=//apache-ant-1.7.0 + MAVEN_HOME=//maven-2.0.6 + export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$MAVEN_HOME/bin:$PATH + +For Windows: + set JAVA_HOME=C:\ + set ANT_HOME=C:\\apache-ant-1.7.0 + set MAVEN_HOME=C:\\maven-2.0.6 + set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin;%MAVEN_HOME%\bin;%PATH% + + +Building And Running The SCA Samples Using Ant +---------------------------------------------- +The build.xml files provided with the Apache Tuscany SCA samples are designed +to work with the binary distribution. They rely on the tuscany-sca-manifest.jar +to describe the class path and this jar is only provided as part of the +binary distribution. + +The binary distribution of SCA also includes precompiled versions of each sample. +If you look in the target directory of each sample you will see this jar file. To +run a sample based on all of the precompiled artifacts all you have to do is: + +cd +ant run + +Check each /README file as some samples require that two progams are +run to get the desired result, for example, the two samples that show how +to build extensions are run from their associated application samples. + +If you want to rebuild a sample, for example, if you have changed it, do the +following: + +cd +ant compile + +Once the sample is built you have the option of running the sample in whatever +way best suits you. Two alternatives are provided in the ant build files. + +The compile target builds the class files and then builds the jar so you can use +the same command as before: + +ant run + +This will use the generated jar to run the samples. The command line version of +this is: + +on Windows + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\ + +for example : java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient + +on *nix + +java -cp ../../features/tuscany-sca-manifest.jar:target/ + +for example : java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator.jar calculator.CalculatorClient + + +You can use the compiled classes directly using + +ant run-classes + +The command line version of this is: + +on Windows + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\classes + +for example : java -cp ..\..\features\tuscany-sca-manifest.jar;target\classes calculator.CalculatorClient + +on *nix + +java -cp ../../features/tuscany-sca-manifest.jar:target/classes + +for example : java -cp ../../features/tuscany-sca-manifest.jar:target/classes calculator.CalculatorClient + +The class specified on the command of course depends on which sample you want to +run. In the examples we have used we are running the CalculatorClient from the calculator sample. + + +Building And Running The SCA Samples Using Maven +------------------------------------------------ + +The Maven build process will work from both source and binary distributions. +To build and test all of the Apache Tuscany SCA sources, including the samples, +do the following. + +cd sca +mvn + +This will take a little while to complete. Experience with Maven tells us that +sometimes there are problems downloading the dependencies that Apache Tuscany +SCA requires. If Maven reports that it cannot download required dependencies +try running the Maven build again. + +Once you have all of the source built you can build and run each sample +independently if required. + +cd +mvn + +When using Maven the samples are run within JUnit test cases and so you will +sometimes not see any test output. You will always see an indication of test +success or failure. + +Using The Samples In An IDE +--------------------------------------------- +The easiest way to use the samples in an IDE is to use Maven to generate all +of the IDE project files for you automatically. This works best if you +generate IDE projects for all of the Apache Tuscany modules. You can then +include the ones you are interested in working with in you IDE. + +To build IDE project files for all of the modules in Apache Tuscany SCA; + +cd sca + +If you are an Eclipse user do the following + +mvn -Peclipse + +If you are an IDEA user do the following + +mvn idea:idea + +These commands generate project files for each module in Apache Tuscany SCA. +The modules you are interested in can now be included in your IDE, for example, +in Eclipse, if you create a new Java project and use the option to "create a +new project from existing source" you can specify an SCA module directory, +which includes the generated project files, and Eclipse will treat it like any +other Java project. + +Using The Samples In An IDE Without Maven +----------------------------------------- +We don't provide any IDE project files with our distributions so you will have to +import the sample files into your IDE manually. Here's an example of how it can be +done using Eclipse. + +In a new or existing workspace + Create a new java project to represent the sample you want to work on, e.g. + calculator + Import all of the sample code and resources into this project, e.g. + File, Import and then select tuscany-sca-1.0-incubating\samples\calculator from the filesystem + Configure the source path to include + src/main/java + src/main/resources + Configure the output folder to be + calculator/target + Configure the build path to include the manifest jar tuscany-sca-manifiest.jar provided in + features + If you select calculator.CalculatorClient.java and run as "Java Application" you should see + 3 + 2=5.0 + 3 - 2=1.0 + 3 * 2=6.0 + 3 / 2=1.5 + +The details of how to do this for other development environments will +vary but the process will be similar. + + diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/README b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/README new file mode 100644 index 0000000000..fb5afcc7ec --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/README @@ -0,0 +1,97 @@ +Calculator Sample +================= +This sample implements a simple calculator using SCA components. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-binding-ws-calculator.jar sample.SampleClientImpl + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-binding-ws-calculator.jar sample.SampleClientImpl + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + Calculator.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator.png - a pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/build.xml b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/build.xml new file mode 100644 index 0000000000..e13ec494b0 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/build.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.png b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.png differ diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.svg b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/calculator.svg @@ -0,0 +1,329 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/pom.xml b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/pom.xml new file mode 100644 index 0000000000..e677c779cc --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-binding-ws-calculator + Apache Tuscany SCA Sample Binding WS Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-feature-api + pom + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-feature-webservice + pom + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-feature-ejava + pom + 2.0-M2 + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..dd7ecb827d --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The Add service interface + */ +@Remotable +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java new file mode 100644 index 0000000000..7e5ff160f0 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorClientImpl.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +import sample.SampleClient; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +public class CalculatorClientImpl implements SampleClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + /** + * This code used to be in an @Init method which removed the need for a JSE client + * to prod the compoite. However OASIS is debating whether to allow references to be used + * inside @Init methods and it can cause deadlocks in our runtime. So rather than make + * changes in the runtime we are falling backon the JSE drive mechanism until we know + * which way the specs are going + */ + public void runSample() { + System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader())); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + + private static String print(ClassLoader cl) { + StringBuffer buf = new StringBuffer(); + for (; cl != null;) { + buf.append(cl.toString()); + buf.append(' '); + cl = cl.getParent(); + } + return buf.toString(); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..17fad7de6b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java new file mode 100644 index 0000000000..6620f6a5e7 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClient.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +/** + * The sample service interface. + */ +public interface SampleClient { + void runSample(); +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.java new file mode 100644 index 0000000000..3f6ecfdb03 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/java/sample/SampleClientImpl.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 sample; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class SampleClientImpl { + public static void main(String[] args) throws Exception { + Node node = NodeFactory.newInstance().createNode(); + + node.start(); + + SampleClient sampleClient = node.getService(SampleClient.class, "SampleClient"); + sampleClient.runSample(); + + node.stop(); + + } + +} diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..29dd7e3b6f --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..27a1ee74e4 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..bc90f0e566 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/binding-ws-calculator/src/test/java/calculator/CalculatorTestCase.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 calculator; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.equinox.launcher.Contribution; +import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper; +import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +import sample.SampleClientImpl; + +/** + * Test the Calculator composition. + */ +public class CalculatorTestCase { + + @Test + public void testSample() throws Exception { + SampleClientImpl.main(null); + } +} diff --git a/tags/java/sca/2.0-M2/samples/build-common.xml b/tags/java/sca/2.0-M2/samples/build-common.xml new file mode 100644 index 0000000000..a0392ac030 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/build-common.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + Distribution: ${distro.root} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/README b/tags/java/sca/2.0-M2/samples/calculator-equinox/README new file mode 100644 index 0000000000..7f76542622 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/README @@ -0,0 +1,97 @@ +Calculator Sample +================= +This sample implements a simple calculator using SCA components. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-equinox.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-equinox.jar calculator.CalculatorClient + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + Calculator.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator.png - a pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/build.xml b/tags/java/sca/2.0-M2/samples/calculator-equinox/build.xml new file mode 100644 index 0000000000..75c4839cfa --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/build.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.png b/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.png differ diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.svg b/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/calculator.svg @@ -0,0 +1,329 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/pom.xml b/tags/java/sca/2.0-M2/samples/calculator-equinox/pom.xml new file mode 100644 index 0000000000..cb052e60ea --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/pom.xml @@ -0,0 +1,91 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-calculator-equinox + Apache Tuscany SCA Sample Calculator Equinox + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 2.0-M2 + runtime + + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 2.0-M2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..84c98d7f70 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + + // Calculate + System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader())); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + + private static String print(ClassLoader cl) { + StringBuffer buf = new StringBuffer(); + for (; cl != null;) { + buf.append(cl.toString()); + buf.append(' '); + cl = cl.getParent(); + } + return buf.toString(); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..17fad7de6b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..9450558145 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..b49e1da130 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-equinox/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.equinox.launcher.Contribution; +import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper; +import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This shows how to test the Calculator composition. + */ +public class CalculatorTestCase { + + private static NodeLauncher launcher; + private static Node node; + + public static void main(String[] args) throws Exception { + setUpBeforeClass(); + tearDownAfterClass(); + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + launcher = NodeLauncher.newInstance(); + String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = launcher.createNode("Calculator.composite", new Contribution("test", location)); + System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader()); + node.start(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node.destroy(); + } + if (launcher != null) { + launcher.destroy(); + } + } + + @Test + public void testDummy() throws Exception { + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/META-INF/MANIFEST.MF b/tags/java/sca/2.0-M2/samples/calculator-osgi/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..56d59b05ff --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Private-Package: calculator;version="2.0.0" +Tool: Bnd-0.0.255 +Bundle-Name: Apache Tuscany SCA Calculator OSGi Sample +Created-By: 1.6.0_07 (Sun Microsystems Inc.) +Bundle-Vendor: The Apache Software Foundation +Eclipse-LazyStart: false +Bundle-Version: 2.0.0 +Bnd-LastModified: 1223949424781 +Bundle-Activator: calculator.CalculatorActivator +Bundle-ManifestVersion: 2 +Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt +Bundle-Description: Apache Tuscany SCA Calculator OSGi Sample +Import-Package: org.apache.tuscany.sca.node;version="2.0.0", + org.oasisopen.sca.annotation;version="2.0.0", + org.osgi.framework;version="1.4" +Bundle-SymbolicName: sample-calculator-osgi +Bundle-DocURL: http://www.apache.org/ + diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/README b/tags/java/sca/2.0-M2/samples/calculator-osgi/README new file mode 100644 index 0000000000..332526d43a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/README @@ -0,0 +1,97 @@ +Calculator Sample +================= +This sample implements a simple calculator using SCA components and run it in a OSGi environment. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -jar ..\..\features\tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ..\..\features\configuration\ -ttl 0 target\sample-calculator-osgi.jar + +and on *nix do + +java -jar ../../features/tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ../../features/configuration/ -ttl 0 target/sample-calculator-osgi.jar + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + Calculator.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator.png - a pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/build.xml b/tags/java/sca/2.0-M2/samples/calculator-osgi/build.xml new file mode 100644 index 0000000000..46522211f9 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/build.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/pom.xml b/tags/java/sca/2.0-M2/samples/calculator-osgi/pom.xml new file mode 100644 index 0000000000..68fae0df29 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/pom.xml @@ -0,0 +1,109 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-calculator-osgi + Apache Tuscany SCA Sample Calculator OSGi + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-feature-api + 2.0-M2 + pom + + + + org.apache.tuscany.sca + tuscany-feature-core + 2.0-M2 + pom + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + maven-eclipse-plugin + 2.5.1 + + + org.eclipse.pde.ManifestBuilder + org.eclipse.jdt.core.javabuilder + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + + org.eclipse.jdt.launching.JRE_CONTAINER + + + + + + + maven-jar-plugin + + + ${basedir}/META-INF/MANIFEST.MF + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java new file mode 100644 index 0000000000..4408568629 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorActivator.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * Bundle Activator for Calculator + * + */ +public class CalculatorActivator implements BundleActivator { + private Node node; + + public void start(BundleContext context) throws Exception { + try { + NodeFactory factory = NodeFactory.newInstance(); + String url = ContributionLocationHelper.getContributionLocation(getClass()); + Contribution contrib = new Contribution("c1", url); + node = factory.createNode("Calculator.composite", contrib); + node.start(); + } catch (Throwable e) { + e.printStackTrace(); + } + } + + public void stop(BundleContext context) throws Exception { + if (node != null) { + node.stop(); + node = null; + } + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..afd5ea48fc --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + // Calculate + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..39f55ca31f --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..9450558145 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..9d9b0a9ffb --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-osgi/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This shows how to test the Calculator composition. + */ +public class CalculatorTestCase { + + private static Node node; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = NodeFactory.newInstance().createNode("Calculator.composite", new Contribution("test", location)); + System.out.println("SCA Node API ClassLoader: " + node.getClass().getClassLoader()); + node.start(); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node.destroy(); + } + } + + @Test + public void testDummy() throws Exception { + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/README b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/README new file mode 100644 index 0000000000..07b6dd9713 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/README @@ -0,0 +1,138 @@ +Calculator RMI Reference Sample +=============================== + +This sample illustrates the use of Tuscany RMI Binding to call reference +services that are hosted as Java RMI services. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, first +navigate to the calculator-rmi-service sample and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-service.jar calculator.CalculatorServer + +Now you have the server running you need to open another command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-reference.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-reference.jar calculator.CalculatorClient + +Sample Overview +--------------- +This sample extends the calculator sample by replacing the local wired +connections with RMI bindings. Instead of local add, subtract, multiply and +divide components, an RMI service implementation now provides the +add, subtract, multiply and divide interfaces and is hosted as an RMI server. +References specified in the .composite file include an RMI binding which targets +this RMI server. + +This sample adds a number of classes to the basic calculator sample: + +calculator-rmi-reference/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - as calculator sample + AddService.java - as calculator sample + SubtractService.java - as calculator sample + MultipleService.java - as calculator sample + DivideService.java - as calculator sample + CalculatorClient.java - as calculator sample + CalculatorServiceImpl.java - calls the RMI service + that provides the target for the + RMI bindings in the composite + resources/ + CalculatorRMIReference.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorRMIReferenceTestCase.java - JUnit test case + CalculatorRMIServiceImpl.java - test RMI service to call + calculator-rmi-reference.png - a pictorial representation of the + .composite file + build.xml - the Ant build file for the client + pom.xml - the Maven build file + +Note. As this test creates and uses local network connections you may need to +configure your firewall, if you are running one, to allow the test to run +successfully. + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant. + +The server provides an RMI server that the acts as a target for the SCA RMI +bindings. Start a new console and use the following commands. + +cd calculator-rmi-service +ant compile +ant run + +This will run up the server and display the following. + +run: + [java] Starting of the SCA Calculator Application exposed as RMI Services... + [java] ...Press Enter to Exit... + +The client is very similar to the calculator sample. It starts the SCA runtime +and calls each of the calculator operations. In doing this the RMI bindings +make calls out to the RMI server you started in the previous step. Start +a new console and use the following commands. + +cd calculator-rmi-reference +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +If you now return to the console window running the server and press enter the +server should stop. + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator-rmi-reference +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorRMIReferenceTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.308 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/build.xml b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/build.xml new file mode 100644 index 0000000000..16d94c3b0b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/build.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.png b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.png new file mode 100644 index 0000000000..8c76b77a9f Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.png differ diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.svg b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.svg new file mode 100644 index 0000000000..ba802e6717 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/calculator-rmi-reference.svg @@ -0,0 +1,412 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + CalculatorServiceRMIImpl + addService + subtractService + multiplyService + divideService + + + + + AddReference + SubtractReference + MultiplyReference + DivideReference + RMIRegistry + + + + + RMI RMI RMI RMI + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/pom.xml b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/pom.xml new file mode 100644 index 0000000000..4c3fe1a757 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/pom.xml @@ -0,0 +1,82 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-calculator-rmi-reference + Apache Tuscany SCA Sample Calculator RMI Reference + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M2 + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M2 + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 2.0-M2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + calculator.CalculatorClient + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the add service + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..3ee36be233 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + String uri = ContributionLocationHelper.getContributionLocation("CalculatorRMIReference.composite"); + Contribution contribution = new Contribution("c1", uri); + Node node = NodeFactory.newInstance().createNode("CalculatorRMIReference.composite", contribution); + node.start(); + CalculatorService calculatorService = node.getService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + node.stop(); + + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..0bac3da45c --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.Remote; +import java.rmi.RemoteException; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The Calculator service interface. + */ +@Remotable +public interface CalculatorService extends Remote { + + double add(double n1, double n2) throws RemoteException; + + double subtract(double n1, double n2) throws RemoteException; + + double multiply(double n1, double n2) throws RemoteException; + + double divide(double n1, double n2) throws RemoteException; +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..675350860e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the divide service + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the subtract service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite new file mode 100644 index 0000000000..a5510954e0 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java new file mode 100644 index 0000000000..b7aa70f122 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import static org.junit.Assert.assertEquals; + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorRMIReferenceTestCase { + + private static Node node; + private static CalculatorService calculatorService; + + @BeforeClass + public static void setUp() throws Exception { + CalculatorRMIServiceImpl rmiCalculatorImpl = new CalculatorRMIServiceImpl(); + Registry rmiRegistry = LocateRegistry.createRegistry(8099); + rmiRegistry.bind("CalculatorRMIService", rmiCalculatorImpl); + + String uri = ContributionLocationHelper.getContributionLocation(CalculatorService.class); + Contribution contribution = new Contribution("c1", uri); + node = NodeFactory.newInstance().createNode("CalculatorRMIReference.composite", contribution); + node.start(); + calculatorService = node.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + LocateRegistry.getRegistry(8099).unbind("CalculatorRMIService"); + } + + @Test + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0, 0.0); + assertEquals(calculatorService.subtract(3, 2), 1.0, 0.0); + assertEquals(calculatorService.multiply(3, 2), 6.0, 0.0); + assertEquals(calculatorService.divide(3, 2), 1.5, 0.0); + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java new file mode 100644 index 0000000000..d8ded42cb2 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.RemoteException; +import java.rmi.server.UnicastRemoteObject; + + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorRMIServiceImpl extends UnicastRemoteObject implements CalculatorService { + + private static final long serialVersionUID = -1543948944662001428L; + + public CalculatorRMIServiceImpl() throws RemoteException { + super(); + } + + public double add(double n1, double n2) throws RemoteException { + return n1 + n2; + } + + public double subtract(double n1, double n2) { + return n1 - n2; + } + + public double multiply(double n1, double n2) { + return n1 * n2; + } + + public double divide(double n1, double n2) { + return n1 / n2; + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/README b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/README new file mode 100644 index 0000000000..144881134b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/README @@ -0,0 +1,147 @@ +Calculator RMI Service Sample +============================= + +This sample illustrates the use of Tuscany RMI Binding to expose component +services as Java RMI Services. It also demonstrates how a simple Java RMI +Client application invokes the SCA Application's services exposed as RMI +Services. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator-rmi-service.jar calculator.CalculatorServer + +Now you have the server running you need to open another command prompt, navigate +to the calculator-rmi-reference sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-rmi-reference.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-rmi-reference.jar calculator.CalculatorClient + + +Sample Overview +--------------- +This sample extends the calculator sample by replacing the local service +binding with an RMI binding. SO a java client can call the service exposed +by the SCA application using an RMI client. + +This sample adds a number of classes to the basic calculator sample: + +calculator-rmi-service/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - as calculator sample + CalculatorServiceImpl.java + AddService.java - as calculator sample + AddServiceImpl.java + SubtractService.java - as calculator sample + SubtractServiceImpl.java + MultiplyService.java - as calculator sample + MultiplyServiceImpl.java + DivideService.java - as calculator sample + DivideServiceImpl.java + CalculatorClient.java - (Not currently used) Uses the + java naming service to + look up the Calculator RMI service. + It then calls add, subtract, multiple + and divide methods on the service + CalculatorServer.java - starts the SCA Runtime and deploys + the CalculatorRMIServer.composite. + In doing this the SCA RMI binding + acts to expose the CalculatorService + over RMI. + resources/ + CalculatorRMIServer.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorRMIServerTestCase.java - JUnit test case + calculator-rmi-service.png - a pictorial representation of the + .composite file + build.xml - the Ant build file for the server + pom.xml - the Maven build file + +Note. As this test creates and uses local network connections you may need to +configure your firewall, if you are running one, to allow the test to run +successfully. + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant. Two +build files are used to support client and server functions. + +The server starts the SCA runtime and loads the SCA calculator application +which exposes an RMI service. Start a new console and use the following +commands. + +cd calculator-rmi-service +ant compile +ant run + +This will run up the server and display the following. + +run: + [java] Starting of the SCA Calculator Application exposed as RMI Services... + [java] ...Press Enter to Exit... + +The client is very similar to the calculator sample + +It locates the RMI service that the SCA runtime is exposing and calls each of +the calculator operations. Start a new console and use the following commands. + +cd calculator-rmi-reference +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +If you now return to the console window running the server and press enter the +server should stop. + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator-rmi-service +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorRMIServerTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.819 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/build.xml b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/build.xml new file mode 100644 index 0000000000..a0889ccc8a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/build.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.png b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.png new file mode 100644 index 0000000000..574f5eb14b Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.png differ diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.svg b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.svg new file mode 100644 index 0000000000..9253110f98 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/calculator-rmi-service.svg @@ -0,0 +1,330 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService(RMI) + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/pom.xml b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/pom.xml new file mode 100644 index 0000000000..88f6e80a15 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/pom.xml @@ -0,0 +1,67 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-calculator-rmi-service + Apache Tuscany SCA Sample Calculator RMI Service + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M2 + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M2 + test + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M2 + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi-runtime + 2.0-M2 + runtime + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the add service + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2b99485b68 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import java.rmi.Naming; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + CalculatorService calculatorService = (CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java new file mode 100644 index 0000000000..ffa40d0234 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * A claculator service server. Starts up the SCA runtime which + * will start listening for RMI service requests. + */ +public class CalculatorServer { + public static void main(String[] args) throws Exception { + System.out.println("Starting of the SCA Calculator Application exposed as RMI Services..."); + String uri = ContributionLocationHelper.getContributionLocation("CalculatorRMIServer.composite"); + Contribution contribution = new Contribution("c1", uri); + Node node = NodeFactory.newInstance().createNode("CalculatorRMIServer.composite", contribution); + node.start(); + System.out.println("... Press Enter to Exit..."); + System.in.read(); + node.stop(); + System.out.println("Exited..."); + System.exit(0); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..b0a46b6dd0 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Remotable; + +/** + * The Calculator service interface. + */ +@Remotable +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..675350860e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the divide service + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the subtract service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite new file mode 100644 index 0000000000..02614ad6e1 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..10140b7bc1 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java new file mode 100644 index 0000000000..eb824679a8 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import static org.junit.Assert.assertEquals; + +import java.rmi.Naming; + +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorRMIServerTestCase { + + private static Node node; + private static CalculatorService calculatorService; + + @BeforeClass + public static void setUp() throws Exception { + String uri = ContributionLocationHelper.getContributionLocation(CalculatorService.class); + Contribution contribution = new Contribution("c1", uri); + node = NodeFactory.newInstance().createNode("CalculatorRMIServer.composite", contribution); + node.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + node.stop(); + } + + @Test + public void testCalculator() throws Exception { + // Calculate + calculatorService = (CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService"); + assertEquals(calculatorService.add(3, 2), 5.0, 0.0); + assertEquals(calculatorService.subtract(3, 2), 1.0, 0.0); + assertEquals(calculatorService.multiply(3, 2), 6.0, 0.0); + assertEquals(calculatorService.divide(3, 2), 1.5, 0.0); + } +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/README b/tags/java/sca/2.0-M2/samples/calculator/README new file mode 100644 index 0000000000..56c22d9c89 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/README @@ -0,0 +1,97 @@ +Calculator Sample +================= +This sample implements a simple calculator using SCA components. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\features\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../features/tuscany-sca-manifest.jar:target/sample-calculator.jar calculator.CalculatorClient + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + Calculator.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator.png - a pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/calculator/build.xml b/tags/java/sca/2.0-M2/samples/calculator/build.xml new file mode 100644 index 0000000000..4411cae659 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/build.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator/calculator.png b/tags/java/sca/2.0-M2/samples/calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/calculator/calculator.png differ diff --git a/tags/java/sca/2.0-M2/samples/calculator/calculator.svg b/tags/java/sca/2.0-M2/samples/calculator/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/calculator.svg @@ -0,0 +1,329 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator/pom.xml b/tags/java/sca/2.0-M2/samples/calculator/pom.xml new file mode 100644 index 0000000000..98287a83a1 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-calculator + Apache Tuscany SCA Sample Calculator + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M2 + runtime + + + + junit + junit + 4.5 + test + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + calculator.CalculatorClient + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..03fc56ceb3 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + + Node node = NodeFactory.newInstance().createNode(); + + node.start(); + + CalculatorService calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + + // Calculate + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + node.stop(); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..17fad7de6b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..f67b212d99 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..10140b7bc1 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..27a424b1cc --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/calculator/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import static org.junit.Assert.assertEquals; + +import org.apache.tuscany.sca.node.Client; +import org.apache.tuscany.sca.node.Contribution; +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Scope; + +/** + * This shows how to test the Calculator service component. + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorTestCase{ + private static Node node; + private static CalculatorService calculatorService; + + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + NodeFactory factory = NodeFactory.newInstance(); + String contribution = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = factory.createNode("Calculator.composite", new Contribution("calculator", contribution)); + node.start(); + + calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + node.stop(); + } + + @Test + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0, 0); + assertEquals(calculatorService.subtract(3, 2), 1.0, 0); + assertEquals(calculatorService.multiply(3, 2), 6.0, 0); + assertEquals(calculatorService.divide(3, 2), 1.5, 0); + } +} diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/README b/tags/java/sca/2.0-M2/samples/helloworld-bpel/README new file mode 100644 index 0000000000..bf5f500ef3 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/README @@ -0,0 +1,151 @@ +Hello World BPEL Sample +====================================== +This sample demonstrates an SCA service implemented by a BPEL process. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory, and do + +ant compile run + +OR if you don't have ant, on Windows do + +mkdir target\classes +mkdir target\wsdl2java-source +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ..\..\lib\tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ..\..\lib\ode-dao-jpa-ojpa-derby-1.1.zip -d target\database +javac -d target\classes -cp target\classes;..\..\lib\tuscany-sca-manifest.jar -sourcepath src\main\java;target\wsdl2java-source -target 1.5 -g -source 1.5 src\main\java\helloworld\BPELClient.java +copy src\main\resources\* target\classes +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes;target\database helloworld.BPELClient + +and on *nix do + +mkdir target/classes +mkdir target/wsdl2java-source +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.sdo.generate.XSD2JavaGenerator -targetDirectory target/wsdl2java-source -prefix HelloWorld -noContainment -noUnsettable src/main/resources/helloworld.wsdl +java -cp ../../lib/tuscany-sca-manifest.jar org.apache.tuscany.tools.wsdl2java.generate.WSDL2JavaGenerator -targetDirectory target/wsdl2java-source src/main/resources/helloworld.wsdl +unzip ../../lib/ode-dao-jpa-ojpa-derby-1.1.zip -d target/database +javac -d target/classes -cp target/classes;../../lib/tuscany-sca-manifest.jar -sourcepath src/main/java;target/wsdl2java-source -target 1.5 -g -source 1.5 src/main/java/helloworld/BPELClient.java +cp src/main/resources/* target/classes +java -cp ../../lib/tuscany-sca-manifest.jar:target/classes:target/database helloworld.BPELClient + +The sample will start an embedded BPEL engine, deploy a process and invoke it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +helloworld-bpel/ + src/ + main/ + java/ + helloworld/ + BPELClient.java - client application for + BEPELHelloWorldComponent + + resources/ + deploy.xml - ODE deployment descriptor + helloworld.bpel - helloworld bpel process + helloworld.componentType - helloworld bpel service description + helloworld.composite - the SCA assembly for this sample + helloworld.wsdl - the service description that describes + the bpel process + log4j.properties - logging configuration + + test/ + java/ + helloworld/ + BPELHelloWorldTestCase.java - JUnit test case + helloworld-bpel.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- + +With the binary distribution the sample can be built and run using Ant as +follows + +cd helloworld-bpel +ant compile +ant run + + +You should see the following output from the run target. + +run: + [java] Starting BPELHelloWorldComponent + [java] >>> Deploying : D:\temp\SCA1.1-RC1\tuscany-sca-1.1-incubating\samples\helloworld-bpel\target\classes + [java] ::arg:::::: + [java] Hello + [java] ::message:: + [java] Hello + [java] Status: RESPONSE + [java] Response: + [java] Hello World + [java] Hello World + [java] Stopping BPELHelloWorldComponent + [java] Stopped !!! + +BUILD SUCCESSFUL +Total time: 36 seconds + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven, a simple test is present that exercise +the same logic as the client to invoke the BPEl process. + +cd helloworld-bpel +mvn + +You should see the following output from the test phase. + +- + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.BPELHelloWorldTestCase +Starting BPELHelloWorldComponent +>>> Deploying : D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\classes +::arg:::::: +Hello +::message:: +Hello +Status: RESPONSE +Response: +Hello World +Stopping BPELHelloWorldComponent +Stopped !!! +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 18.656 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +[INFO] [jar:jar] +[INFO] Building jar: D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar +[INFO] [install:install] +[INFO] Installing D:\dev\Opensource\Apache\Tuscany\source\java-sca-1.1\samples\helloworld-bpel\target\sample-helloworld-bpel.jar to C:\Documents and Settings\lresend +e\.m2\repository\org\apache\tuscany\sca\sample-helloworld-bpel\1.1-incubating-SNAPSHOT\sample-helloworld-bpel-1.1-incubating-SNAPSHOT.jar +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESSFUL +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 53 seconds +[INFO] Finished at: Sun Jan 13 09:54:39 PST 2008 +[INFO] Final Memory: 24M/43M +[INFO] ------------------------------------------------------------------------ + + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/build.xml b/tags/java/sca/2.0-M2/samples/helloworld-bpel/build.xml new file mode 100644 index 0000000000..890a6427b8 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/build.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.png b/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.png new file mode 100644 index 0000000000..5f53a3c5d1 Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.png differ diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.svg b/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.svg new file mode 100644 index 0000000000..5a98f1a07c --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/helloworld-bpel.svg @@ -0,0 +1,179 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + implementation.bpel helloworld.bpel + + diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/pom.xml b/tags/java/sca/2.0-M2/samples/helloworld-bpel/pom.xml new file mode 100644 index 0000000000..447f91a952 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/pom.xml @@ -0,0 +1,198 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-helloworld-bpel + Apache Tuscany SCA Sample HelloWorld BPEL + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-M2 + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-bpel-ode + 2.0-M2 + runtime + + + + + + xerces + xercesImpl + 2.8.1 + + + + junit + junit + 4.5 + test + + + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + javax.xml.bind + jaxb-api + 2.1 + compile + + + javax.xml.stream + stax-api + + + + + + com.sun.xml.bind + jaxb-impl + 2.1.7 + runtime + + + + + + ${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/ + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java new file mode 100644 index 0000000000..e2d69eddf6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/BPELClient.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * Simple BPEL sample application invoking a helloworld + * + * @version $Rev$ $Date$ + */ +public class BPELClient { + public static void main(String[] args) throws Exception { + + Node node = NodeFactory.newInstance().createNode(); + node.start(); + + Hello bpelService = node.getService(Hello.class, "BPELHelloWorldComponent"); + + String result = bpelService.hello("Hello"); + System.out.println(result); + + node.stop(); + + System.exit(0); + } +} diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java new file mode 100644 index 0000000000..ae7be07be6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/java/helloworld/Hello.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import org.oasisopen.sca.annotation.Remotable; + +@Remotable +public interface Hello { + + String hello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8378a15824 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,23 @@ + + + + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.bpel b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.bpel new file mode 100644 index 0000000000..a88aa7960c --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.bpel @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + concat($tmpVar,' World') + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.composite b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.composite new file mode 100644 index 0000000000..91ce1f22d4 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl new file mode 100644 index 0000000000..46cf381577 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/helloworld.wsdl @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/log4j.properties b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/log4j.properties new file mode 100644 index 0000000000..8649a71550 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/main/resources/log4j.properties @@ -0,0 +1,35 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Set root logger level to WARN and its only appender to CONSOLE +log4j.rootLogger=OFF, CONSOLE + +# log4j properties to work with commandline tools. +log4j.category.org.mortbay=OFF +log4j.category.org.hibernate.type=OFF +log4j.category.org.objectweb=OFF +log4j.category.org.apache.ode.sql=OFF +log4j.category.org.apache.ode.axis2=OFF +log4j.category.org.apache.ode.bpel.engine=OFF +log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF +log4j.category.org.apache.ode.bpel.epr=OFF +log4j.category.org.apache.openjpa.kernel=OFF + +# Console appender +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=%p - %C{1}.%M(%L) | %m%n \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java.FIXME b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java.FIXME new file mode 100644 index 0000000000..3b85fa85a2 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/helloworld-bpel/src/test/java/helloworld/BPELHelloWorldTestCase.java.FIXME @@ -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 helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.node.ContributionLocationHelper; +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.NodeFactory; + +/** + * Tests the BPEL service + * + * @version $Rev$ $Date$ + */ +public class BPELHelloWorldTestCase extends TestCase { + + private Node node; + private Hello bpelService; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + + node = NodeFactory.newInstance().createNode(); + node.start(); + + bpelService = node.getService(Hello.class, "BPELHelloWorldComponent"); + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + node.stop(); + } + + public void testInvoke() throws Exception { + String response = bpelService.hello("Hello"); + assertEquals("Hello World", response); + } +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/README b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/README new file mode 100644 index 0000000000..28eccbdebb --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/README @@ -0,0 +1,96 @@ +Calculator Sample +================= +This sample implements a simple calculator using SCA components. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open a command prompt, navigate +to this sample directory and do: + +ant run + +OR if you don't have ant, on Windows do + +java -jar ..\..\features\tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ..\..\features\configuration\ -ttl 0 target\sample-implementation-java-calculator.jar +and on *nix do + +java -jar ../../features/tuscany-sca-equinox-manifest.jar -composite Calculator.composite -config ../../features/configuration/ -ttl 0 target/sample-implementation-java-calculator.jar + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. The CalculatorClient exercises this interface by calling add, +subtract, multiply and divide operations. This results in messages passing to +the appropriate components in the composite across the local wires. + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + Calculator.composite - the SCA assembly for this sample + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator.png - a pictorial representation of the sample + .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] 3 + 2=5.0 + [java] 3 - 2=1.0 + [java] 3 * 2=6.0 + [java] 3 / 2=1.5 + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. + +cd calculator +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.CalculatorTestCase +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.272 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/build.xml b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/build.xml new file mode 100644 index 0000000000..494cfbd811 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/build.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.png b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.png differ diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.svg b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.svg new file mode 100644 index 0000000000..af34f07e04 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/calculator.svg @@ -0,0 +1,329 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/pom.xml b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/pom.xml new file mode 100644 index 0000000000..7f66dce324 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + sample-implementation-java-calculator + Apache Tuscany SCA Sample Implementation Java Calculator + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-feature-api + pom + 2.0-M2 + + + + org.apache.tuscany.sca + tuscany-feature-core + pom + 2.0-M2 + + + + junit + junit + 4.5 + test + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..84c98d7f70 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") @EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + + // Calculate + System.out.println("SCA API ClassLoader: " + print(Reference.class.getClassLoader())); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + + private static String print(ClassLoader cl) { + StringBuffer buf = new StringBuffer(); + for (; cl != null;) { + buf.append(cl.toString()); + buf.append(' '); + cl = cl.getParent(); + } + return buf.toString(); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..17fad7de6b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.oasisopen.sca.annotation.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/resources/Calculator.composite b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..9450558145 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/main/resources/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..461c970373 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/implementation-java-calculator/src/test/java/calculator/CalculatorTestCase.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.apache.tuscany.sca.node.Node; +import org.apache.tuscany.sca.node.equinox.launcher.Contribution; +import org.apache.tuscany.sca.node.equinox.launcher.ContributionLocationHelper; +import org.apache.tuscany.sca.node.equinox.launcher.NodeLauncher; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This shows how to test the Calculator composition. + */ +public class CalculatorTestCase { + + private static NodeLauncher launcher; + private static Node node; + private static String status = "Sample Success"; + + public static void main(String[] args) throws Exception { + setUpBeforeClass(); + tearDownAfterClass(); + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + launcher = NodeLauncher.newInstance(); + String location = ContributionLocationHelper.getContributionLocation(CalculatorClient.class); + node = launcher.createNode("Calculator.composite", new Contribution("test", location)); + + try { + node.start(); + } catch (Exception ex) { + status = ex.toString(); + System.out.println(status); + } + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + if (node != null) { + node.stop(); + node.destroy(); + } + if (launcher != null) { + launcher.destroy(); + } + } + + @Test + public void testSample() throws Exception { + Assert.assertEquals("Sample Success", status); + } +} diff --git a/tags/java/sca/2.0-M2/samples/logging.properties b/tags/java/sca/2.0-M2/samples/logging.properties new file mode 100644 index 0000000000..cf452e7812 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/logging.properties @@ -0,0 +1,25 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +handlers= java.util.logging.ConsoleHandler + +.level = INFO + +java.util.logging.ConsoleHandler.level = FINE +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter + +org.apache.tuscany.sca.level = INFO diff --git a/tags/java/sca/2.0-M2/samples/pom.xml b/tags/java/sca/2.0-M2/samples/pom.xml new file mode 100644 index 0000000000..73addba1f8 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../pom.xml + + tuscany-samples + pom + Apache Tuscany SCA Samples + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + default + + true + + + helloworld-bpel + calculator + calculator-equinox + calculator-osgi + calculator-rmi-reference + calculator-rmi-service + + implementation-java-calculator + binding-ws-calculator + + + webapps/helloworld + webapps/helloworld-jsp + webapps/helloworld-stripes + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/pom.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/pom.xml new file mode 100644 index 0000000000..2aa4372820 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/pom.xml @@ -0,0 +1,62 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + + helloworld-jsf + Apache Tuscany SCA Sample Helloworld JSF + war + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 2.0-M2 + runtime + + + + org.apache.myfaces.core + myfaces-impl + 1.2.3 + runtime + + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java new file mode 100644 index 0000000000..931c1ad820 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloWorldController.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.Reference; + +/** + * + */ +public class HelloWorldController { + + @Reference + protected HelloworldService service; + + private String name; + + public HelloWorldController() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Method that is backed to a submit button of a form. + */ + public String send() { + if (service == null) { + name = "reference not injected!"; + } else { + name = service.sayHello(name); + } + return "success"; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..123774b936 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..6db7e93188 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml new file mode 100644 index 0000000000..3a51ed2623 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/faces-config.xml @@ -0,0 +1,51 @@ + + + + + + + helloWorld + sample.HelloWorldController + request + + + + + /helloWorld.jsp + + success + /page2.jsp + + + + + + /page2.jsp + + back + /helloWorld.jsp + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..7e2ca0a158 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..7fd6bd6b6b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,181 @@ + + + + + MyProject web.xml + + + + 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 + + + + + org.apache.myfaces.webapp.StartupServletContextListener + + + + + Faces Servlet + javax.faces.webapp.FacesServlet + 1 + + + + + Faces Servlet + *.jsf + + + + + index.jsp + index.html + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp new file mode 100644 index 0000000000..189c142c99 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/helloWorld.jsp @@ -0,0 +1,40 @@ + + +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> + + + + Apache Tuscany Helloworld JSF sample + + +

Apache Tuscany Helloworld JSF sample

+ + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp new file mode 100644 index 0000000000..5ca296e115 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/index.jsp @@ -0,0 +1,23 @@ + + +<%@ page session="false"%> +<% +response.sendRedirect("helloWorld.jsf"); +%> diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp new file mode 100644 index 0000000000..89259021c7 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsf/src/main/webapp/page2.jsp @@ -0,0 +1,38 @@ + + +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> + + + Apache Tuscany Helloworld JSF sample + + +

Apache Tuscany Helloworld JSF sample

+ + + +
+ + + +
+
+ + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/pom.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/pom.xml new file mode 100644 index 0000000000..9e96e78b2f --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + + helloworld-jsp + war + Apache Tuscany SCA Sample Helloworld JSP + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M2 + compile + + + + org.apache.tuscany.sca + tuscany-implementation-web-runtime + 2.0-M2 + runtime + + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..123774b936 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..66cef71a25 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + + +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..56ed55b2d5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..a5b03d4904 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,41 @@ + + + + + Apache Tuscany Helloworld JSP Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + + hello.jsp + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp new file mode 100644 index 0000000000..ffd01cca73 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-jsp/src/main/webapp/hello.jsp @@ -0,0 +1,37 @@ + + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<%@ taglib uri="http://www.osoa.org/sca/sca_jsp.tld" prefix="sca" %> + + + + + + +

Apache Tuscany Helloworld JSP Sample

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

+ + <%= service.sayHello("world") %> + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/pom.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/pom.xml new file mode 100644 index 0000000000..8ea6d65d9e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + + helloworld-stripes + war + Apache Tuscany SCA Sample Helloworld using Stripes + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M2 + + + org.apache.tuscany.sca + tuscany-stripes + 2.0-M2 + + + + + net.sourceforge.stripes + stripes + 1.5 + + + taglibs + standard + 1.1.2 + + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java new file mode 100644 index 0000000000..98c35dd431 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/BaseActionBean.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mystripes.action; + +import net.sourceforge.stripes.action.ActionBean; +import net.sourceforge.stripes.action.ActionBeanContext; + +public class BaseActionBean implements ActionBean { + private ActionBeanContext context; + + public ActionBeanContext getContext() { + return context; + } + public void setContext(ActionBeanContext context) { + this.context = context; + } +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java new file mode 100644 index 0000000000..75ee7c2843 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/mystripes/action/HomeActionBean.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package mystripes.action; + +import net.sourceforge.stripes.action.DefaultHandler; +import net.sourceforge.stripes.action.ForwardResolution; +import net.sourceforge.stripes.action.Resolution; +import net.sourceforge.stripes.action.UrlBinding; + +import org.oasisopen.sca.annotation.Reference; + +import sample.HelloworldService; + +@UrlBinding("/Home.htm") +public class HomeActionBean extends BaseActionBean { + + @Reference + HelloworldService service; + + @DefaultHandler + public Resolution view() { + return new ForwardResolution("/WEB-INF/jsp/home.jsp"); + } + + public String getHello() { + return service.sayHello("world"); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..123774b936 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..66cef71a25 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + + +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties new file mode 100644 index 0000000000..a23399569a --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/StripesResources.properties @@ -0,0 +1,57 @@ + +# 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=
+ +# Resource strings used by the tag when displaying errors for a +# specific field (e.g. ). If not supplied the +# values above will be used instead. +stripes.fieldErrors.header= +stripes.fieldErrors.beforeError= +stripes.fieldErrors.afterError=
+stripes.fieldErrors.footer= + +# Resource strings used by the stripes:messages tag +stripes.messages.header=
    +stripes.messages.beforeMessage=
  • +stripes.messages.afterMessage=
  • +stripes.messages.footer=
+ +# Validation error messages produced by Stripes' built-in converter classes. These +# are default error messages and can be overridden on per-field and per-form levels. +# Using the 'invalidNumber' error for a field 'age' of a form posting to +# '/user/Profile.action', the keys looked for (in order) would be: +# 1: /user/Profile.action.age.invalidNumber +# 2: /user/Profile.action.age.errorMessage +# 3: age.errorMessage +# 4: /user/Profile.action.invalidNumber +# 5: converter.number.invalidNumber +converter.number.invalidNumber=The value ({1}) entered in field {0} must be a valid number +converter.byte.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3} +converter.short.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3} +converter.integer.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3} +converter.float.outOfRange=The value ({1}) entered in field {0} was out of the range {2} to {3} +converter.enum.notAnEnumeratedValue=The value "{1}" is not a valid value for field {0} +converter.date.invalidDate=The value ({1}) entered in field {0} must be a valid date +converter.email.invalidEmail=The value ({1}) entered is not a valid email address +converter.creditCard.invalidCreditCard=The value ({1}) entered is not a valid credit card number + +# Validation error messages produced by Stripes' annotation based validations. These +# are default error messages and can be overridden on per-field and per-form levels. +# Using the 'valueNotPresent' required field error for a field 'username' of a form +# posting to '/user/Register.action', the keys looked for (in order) would be: +# 1: /user/Register.action.username.valueNotPresent +# 2: /user/Register.action.username.errorMessage +# 3: username.errorMessage +# 4: /user/Register.action.valueNotPresent +# 5: validation.required.valueNotPresent +validation.required.valueNotPresent={0} is a required field +validation.minlength.valueTooShort={0} must be at least {2} characters long +validation.maxlength.valueTooLong={0} must be no more than {2} characters long +validation.minvalue.valueBelowMinimum=The minimum allowed value for {0} is {2} +validation.maxvalue.valueAboveMaximum=The maximum allowed value for {0} is {2} +validation.mask.valueDoesNotMatch={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/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties new file mode 100644 index 0000000000..77fa204a15 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/resources/log4j.properties @@ -0,0 +1,31 @@ +# log4j.properties + +# Set up a logger to the console +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n + +# Use this to only see log messages beyond a certain threshold in the console +#log4j.appender.stdout.Threshold=WARN + +# Set up a logger to a log file +log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender +log4j.appender.logfile.layout=org.apache.log4j.PatternLayout +log4j.appender.logfile.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p %c %x - %m%n +log4j.appender.logfile.File=${user.home}/stripesquick.log +log4j.appender.logfile.DatePattern='.'yyyy-MM-dd + +# Use this to only see log messages beyond a certain threshold in the log file +#log4j.appender.logfile.Threshold=WARN + +# Logger settings +log4j.rootLogger=INFO, stdout, logfile + +# Valid levels are TRACE, DEBUG, INFO, WARN, ERROR, FATAL +# Change to TRACE or DEBUG to see more log messages +log4j.logger.net.sourceforge.stripes=WARN +log4j.logger.org.stripesbook.quickstart=INFO +log4j.logger.org.mortbay.log=INFO +log4j.logger.org=WARN +log4j.logger.com=WARN +log4j.logger.net=WARN diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp new file mode 100644 index 0000000000..0681c1f2bf --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/home.jsp @@ -0,0 +1,26 @@ + +<%@ include file="/WEB-INF/jsp/taglibs.jsp" %> + + + +

sayHello returns: ${actionBean.hello}

+

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

+
+
diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp new file mode 100644 index 0000000000..d0fb716b80 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/layout.jsp @@ -0,0 +1,39 @@ + +<%@ include file="/WEB-INF/jsp/taglibs.jsp" %> + + + + + + + ${title} + + + + + +
+ + +
+ + + +
\ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp new file mode 100644 index 0000000000..f85602fcfa --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/jsp/taglibs.jsp @@ -0,0 +1,29 @@ + +<%-- Stripes TLD --%> +<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %> +<%@ taglib prefix="sdyn" uri="http://stripes.sourceforge.net/stripes-dynattr.tld" %> + +<%-- JSTL TLDs --%> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> +<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> + +<%-- This is so that you can conveniently refer to the context path with ${contextPath} --%> + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..56ed55b2d5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..0a16144519 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,61 @@ + + + + + Apache Tuscany Helloworld Stripes Sample + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + StripesFilter + net.sourceforge.stripes.controller.StripesFilter + + ActionResolver.Packages + mystripes.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/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/index.html b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/index.html new file mode 100644 index 0000000000..c79d29e6a5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-stripes/src/main/webapp/index.html @@ -0,0 +1,24 @@ + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/pom.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/pom.xml new file mode 100644 index 0000000000..42a817123e --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + + helloworld-wicket + war + Apache Tuscany SCA Sample Helloworld using Wicket + + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M2 + + + org.apache.tuscany.sca + tuscany-wicket + 2.0-M2 + + + javax.servlet + servlet-api + 2.5 + provided + + + + + org.apache.wicket + wicket + 1.4-rc2 + + + org.slf4j + slf4j-log4j12 + 1.4.2 + + + log4j + log4j + 1.2.14 + + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..123774b936 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..66cef71a25 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + + +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html new file mode 100644 index 0000000000..61eb207e23 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.html @@ -0,0 +1,48 @@ + + + + + Wicket Examples - guice + + + +

+ This page uses Google Guice. + There is a service interface called IMyService, with an implementation POJO called MyService. + Guice is used to wire the implementation into the Page using an @Inject annotation. You can use this + annotation on the fields of any Component subclass. +

+

+ The value of the Label component below will be updated with the return value from one of the service's methods when you click the link. +

+
+
+ Value: Message goes here +
+ To update the label above, click here. +
+
+

+ The wicket-guice project will take care of proxying the injected beans so that your pages can be serialized safely. + To configure your application for Guice injection, see the javadoc for GuiceComponentInjector. +

+ + + \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java new file mode 100644 index 0000000000..89b8d7eba4 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/HomePage.java @@ -0,0 +1,66 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample.wicket; + +import org.apache.wicket.markup.html.WebPage; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.Link; +import org.apache.wicket.model.AbstractReadOnlyModel; +import org.oasisopen.sca.annotation.Reference; + +/** + * Everybody's favorite example (Hello World), modified to use Guice. + * + * @author Alastair Maw + */ +public class HomePage extends WebPage +{ + @Reference + IMyService service; + + private String labelValue = ""; + + /** + * Constructor + */ + public HomePage() + { + add(new Link("link") + { + /** + * @see org.apache.wicket.markup.html.link.Link#onClick() + */ + @Override + public void onClick() + { + labelValue = service.getHelloWorldText(); + } + }); + add(new Label("message", new AbstractReadOnlyModel() + { + + @Override + public String getObject() + { + return labelValue; + } + + })); + } +} \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java new file mode 100644 index 0000000000..ab72a2b0f5 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/IMyService.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample.wicket; + + +/** + * Service interface for a simple "Hello World" app. + * + * @author Alastair Maw + */ +public interface IMyService +{ + /** + * Retrieves the text to say "Hello World". + * + * @return "Hello World" + */ + public String getHelloWorldText(); +} \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java new file mode 100644 index 0000000000..34d4dad625 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/MyService.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample.wicket; + + +/** + * Implementation of IService. + * + * @author Alastair Maw + */ +public class MyService implements IMyService +{ + + /** + * @see org.apache.wicket.examples.guice.service.IMyService#getHelloWorldText() + */ + public String getHelloWorldText() + { + return "Hello World"; + } + +} \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java new file mode 100644 index 0000000000..d26b729898 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/java/sample/wicket/WicketApplication.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample.wicket; + +import org.apache.wicket.Page; +import org.apache.wicket.protocol.http.WebApplication; +import org.apache.tuscany.sca.wicket.TuscanyComponentInjector;; + +/** + * Application object for your web application. If you want to run this application without deploying, run the Start class. + * + * @see com.mycompany.Start#main(String[]) + */ +public class WicketApplication extends WebApplication +{ + + @Override + protected void init() + { + addComponentInstantiationListener(new TuscanyComponentInjector(this)); + } + + /** + * @see org.apache.wicket.Application#getHomePage() + */ + @Override + public Class< ? extends Page> getHomePage() + { + return HomePage.class; + } +} \ No newline at end of file diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties new file mode 100644 index 0000000000..822153c0e2 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/resources/log4j.properties @@ -0,0 +1,29 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +log4j.appender.Stdout=org.apache.log4j.ConsoleAppender +log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n + +log4j.rootLogger=INFO,Stdout + +log4j.logger.org.apache.wicket=INFO +log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=INFO +log4j.logger.org.apache.wicket.version=INFO +log4j.logger.org.apache.wicket.RequestCycle=INFO + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..7e2ca0a158 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..7b8490b2be --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld-wicket/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,50 @@ + + + + + Apache Tuscany Helloworld Wicket Sample + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + + + wicket.tuscany + org.apache.wicket.protocol.http.WicketFilter + + applicationClassName + sample.wicket.WicketApplication + + + + + wicket.tuscany + /* + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld/pom.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld/pom.xml new file mode 100644 index 0000000000..5762a6a66b --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld/pom.xml @@ -0,0 +1,55 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-M2 + ../../pom.xml + + + helloworld + Apache Tuscany SCA Sample Helloworld + war + + + + + org.apache.tuscany.sca + tuscany-sca-api + 2.0-M2 + compile + + + + org.apache.tuscany.sca + tuscany-host-webapp + 2.0-M2 + runtime + + + + + + ${artifactId} + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java new file mode 100644 index 0000000000..123774b936 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldService.java @@ -0,0 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +public interface HelloworldService { + + String sayHello(String name); + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java new file mode 100644 index 0000000000..010ca34f00 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/java/sample/HelloworldServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package sample; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Scope; + +@EagerInit +@Scope("COMPOSITE") +public class HelloworldServiceImpl implements HelloworldService { + + public String sayHello(String name) { + return "Hello " + name; + } + + @Init + public void init() { + System.out.println(sayHello("world")); + } + +} diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite new file mode 100644 index 0000000000..f0609d9eb9 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..f13afbfb74 --- /dev/null +++ b/tags/java/sca/2.0-M2/samples/webapps/helloworld/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,37 @@ + + + + + Apache Tuscany Helloworld Sample + + + tuscany + org.apache.tuscany.sca.host.webapp.TuscanyServletFilter + + + + tuscany + /* + + + -- cgit v1.2.3