From 3dd7e2c4da9c80b8182a2d04dc129a67aa7910df Mon Sep 17 00:00:00 2001 From: lresende Date: Wed, 11 Nov 2009 23:06:58 +0000 Subject: Moving 1.x branches git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835121 13f79535-47bb-0310-9956-ffa450edef68 --- sca-java-1.x/branches/sca-java-0.99/samples/README | 271 +++++++ .../samples/binding-echo-extension/README | 74 ++ .../samples/binding-echo-extension/build.xml | 51 ++ .../samples/binding-echo-extension/pom.xml | 78 ++ .../src/main/java/echo/EchoBinding.java | 30 + .../src/main/java/echo/EchoBindingFactory.java | 33 + .../java/echo/impl/EchoBindingFactoryImpl.java | 34 + .../src/main/java/echo/impl/EchoBindingImpl.java | 83 ++ .../main/java/echo/impl/EchoBindingProcessor.java | 155 ++++ .../java/echo/provider/EchoBindingInvoker.java | 48 ++ .../echo/provider/EchoBindingPoliciedInvoker.java | 71 ++ .../echo/provider/EchoBindingProviderFactory.java | 58 ++ .../provider/EchoReferenceBindingProvider.java | 74 ++ .../echo/provider/EchoServiceBindingProvider.java | 74 ++ .../policy/EchoBindingEncryptionPolicy.java | 41 + .../EchoBindingEncryptionPolicyProcessor.java | 36 + .../echo/provider/policy/EchoBindingPolicy.java | 43 + .../policy/EchoBindingPolicyProcessor.java | 78 ++ .../provider/policy/EncryptionPolicyHandler.java | 48 ++ .../echo/provider/policy/EncryptionStrategy.java | 26 + .../java/echo/provider/policy/PolicyHandler.java | 29 + .../provider/policy/ReverseEncryptionStrategy.java | 33 + .../main/java/echo/provider/policy/WSPolicy.java | 43 + .../echo/provider/policy/WSPolicyProcessor.java | 60 ++ .../src/main/java/echo/server/EchoServer.java | 78 ++ .../main/java/echo/server/EchoServiceListener.java | 52 ++ .../META-INF/services/echo.EchoBindingFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 21 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../src/test/java/echo/Echo.java | 29 + .../src/test/java/echo/EchoComponentImpl.java | 44 + .../src/test/java/echo/EchoReferenceTestCase.java | 50 ++ .../src/test/java/echo/EchoServiceTestCase.java | 50 ++ .../src/test/resources/EchoBinding.composite | 41 + .../src/test/resources/definitions.xml | 198 +++++ .../sca-java-0.99/samples/binding-echo/README | 99 +++ .../samples/binding-echo/binding-echo.png | Bin 0 -> 7846 bytes .../samples/binding-echo/binding-echo.svg | 174 ++++ .../sca-java-0.99/samples/binding-echo/build.xml | 75 ++ .../sca-java-0.99/samples/binding-echo/pom.xml | 71 ++ .../binding-echo/src/main/java/echo/Echo.java | 29 + .../src/main/java/echo/EchoBindingClient.java | 51 ++ .../src/main/java/echo/EchoComponentImpl.java | 44 + .../src/main/resources/EchoBinding.composite | 40 + .../src/test/java/echo/EchoBindingTestCase.java | 57 ++ .../samples/binding-notification-broker/README | 95 +++ .../binding-notification-broker.png | Bin 0 -> 36945 bytes .../samples/binding-notification-broker/pom.xml | 76 ++ .../java/notification/broker/TestCaseProducer.java | 24 + .../java/notification/broker/TrafficAdvisory.java | 30 + .../broker/TrafficAdvisoryConsumer.java | 39 + .../broker/TrafficAdvisoryProducer.java | 36 + .../notification/broker/TrafficAdvisoryServer.java | 69 ++ .../TrafficAdvisoryNotification.componentType | 36 + .../TrafficAdvisoryNotification.composite | 63 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../samples/binding-notification-consumer/README | 89 ++ .../binding-notification-consumer.png | Bin 0 -> 27279 bytes .../samples/binding-notification-consumer/pom.xml | 96 +++ .../notification/consumer/TrafficAdvisory.java | 30 + .../consumer/TrafficAdvisoryConsumer.java | 39 + .../consumer/TrafficAdvisoryServer.java | 46 ++ .../TrafficAdvisoryNotification.componentType | 36 + .../TrafficAdvisoryNotification.composite | 54 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../samples/binding-notification-producer/README | 118 +++ .../binding-notification-producer.png | Bin 0 -> 21631 bytes .../samples/binding-notification-producer/pom.xml | 100 +++ .../notification/producer/TestCaseProducer.java | 24 + .../notification/producer/TrafficAdvisory.java | 30 + .../producer/TrafficAdvisoryProducer.java | 36 + .../producer/TrafficAdvisoryServer.java | 54 ++ .../TrafficAdvisoryNotification.componentType | 36 + .../TrafficAdvisoryNotification.composite | 45 ++ .../src/main/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../producer/TrafficAdvisoryTestCase.java | 56 ++ .../TrafficAdvisoryNotification.componentType | 36 + .../TrafficAdvisoryNotification.composite | 45 ++ .../src/test/resources/wsdl/TrafficAdvisory.wsdl | 50 ++ .../samples/calculator-distributed/README | 297 +++++++ .../samples/calculator-distributed/build.xml | 229 ++++++ .../calculator-distributed.png | Bin 0 -> 76839 bytes .../calculator-distributed.svg | 383 +++++++++ .../samples/calculator-distributed/pom.xml | 101 +++ .../src/main/java/calculator/AddService.java | 31 + .../src/main/java/calculator/AddServiceImpl.java | 31 + .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 74 ++ .../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 | 31 + .../main/java/calculator/SubtractServiceImpl.java | 31 + .../src/main/java/node/CalculatorNode.java | 114 +++ .../src/main/java/node/DomainNode.java | 47 ++ .../resources/domain/META-INF/sca-contribution.xml | 24 + .../src/main/resources/domain/domain.composite | 43 + .../management/META-INF/sca-contribution.xml | 24 + .../main/resources/management/management.composite | 41 + .../src/main/resources/nodeA/Calculator.composite | 41 + .../resources/nodeA/META-INF/sca-contribution.xml | 24 + .../src/main/resources/nodeB/Calculator.composite | 29 + .../resources/nodeB/META-INF/sca-contribution.xml | 24 + .../src/main/resources/nodeC/Calculator.composite | 32 + .../resources/nodeC/META-INF/sca-contribution.xml | 24 + .../java/calculator/DomainInMemoryTestCase.java | 115 +++ .../samples/calculator-rmi-reference/README | 138 ++++ .../samples/calculator-rmi-reference/build.xml | 72 ++ .../calculator-rmi-reference.png | Bin 0 -> 23615 bytes .../calculator-rmi-reference.svg | 412 ++++++++++ .../samples/calculator-rmi-reference/pom.xml | 68 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/CalculatorClient.java | 44 + .../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 | 60 ++ .../java/calculator/CalculatorRMIServiceImpl.java | 52 ++ .../samples/calculator-rmi-service/README | 147 ++++ .../samples/calculator-rmi-service/build.xml | 72 ++ .../calculator-rmi-service.png | Bin 0 -> 20814 bytes .../calculator-rmi-service.svg | 330 ++++++++ .../samples/calculator-rmi-service/pom.xml | 68 ++ .../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 | 39 + .../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 ++ .../calculator/CalculatorRMIServerTestCase.java | 53 ++ .../sca-java-0.99/samples/calculator-script/README | 105 +++ .../samples/calculator-script/build.xml | 72 ++ .../calculator-script/calculator-script.png | Bin 0 -> 23064 bytes .../calculator-script/calculator-script.svg | 334 ++++++++ .../samples/calculator-script/pom.xml | 78 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/CalculatorClient.java | 43 + .../main/java/calculator/CalculatorService.java | 34 + .../java/calculator/CalculatorServiceImpl.java | 69 ++ .../src/main/java/calculator/DivideService.java | 28 + .../src/main/java/calculator/MultiplyService.java | 28 + .../src/main/java/calculator/SubtractService.java | 28 + .../src/main/resources/Calculator.composite | 50 ++ .../main/resources/calculator/AddServiceImpl.js | 22 + .../resources/calculator/DivideServiceImpl.groovy | 22 + .../resources/calculator/MultiplyServiceImpl.py | 20 + .../resources/calculator/SubtractServiceImpl.rb | 21 + .../test/java/calculator/CalculatorTestCase.java | 52 ++ .../samples/calculator-webapp-ws/README | 117 +++ .../samples/calculator-webapp-ws/build.xml | 148 ++++ .../calculator-webapp-ws/calculator-web.png | Bin 0 -> 25757 bytes .../calculator-webapp-ws/calculator-web.svg | 455 +++++++++++ .../samples/calculator-webapp-ws/pom.xml | 85 ++ .../src/main/java/calculator/AddService.java | 31 + .../src/main/java/calculator/AddServiceImpl.java | 34 + .../src/main/java/calculator/CalculatorClient.java | 47 ++ .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 69 ++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 30 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 30 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../src/main/resources/Calculator.composite | 61 ++ .../src/main/resources/wsdl/add.wsdl | 87 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../src/main/webapp/WEB-INF/web.xml | 45 ++ .../calculator-webapp-ws/src/main/webapp/calc.jsp | 50 ++ .../sca-java-0.99/samples/calculator-webapp/README | 118 +++ .../samples/calculator-webapp/build.xml | 86 ++ .../samples/calculator-webapp/calculator-web.png | Bin 0 -> 22916 bytes .../samples/calculator-webapp/calculator-web.svg | 358 +++++++++ .../samples/calculator-webapp/pom.xml | 65 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 30 + .../src/main/java/calculator/CalculatorClient.java | 47 ++ .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 69 ++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 30 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 30 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../src/main/resources/Calculator.composite | 49 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../src/main/webapp/WEB-INF/web.xml | 35 + .../calculator-webapp/src/main/webapp/calc.jsp | 50 ++ .../test/java/calculator/CalculatorTestCase.java | 52 ++ .../sca-java-0.99/samples/calculator/README | 97 +++ .../sca-java-0.99/samples/calculator/build.xml | 72 ++ .../samples/calculator/calculator.png | Bin 0 -> 20552 bytes .../samples/calculator/calculator.svg | 329 ++++++++ .../sca-java-0.99/samples/calculator/pom.xml | 64 ++ .../src/main/java/calculator/AddService.java | 28 + .../src/main/java/calculator/AddServiceImpl.java | 30 + .../src/main/java/calculator/CalculatorClient.java | 45 ++ .../main/java/calculator/CalculatorService.java | 35 + .../java/calculator/CalculatorServiceImpl.java | 70 ++ .../src/main/java/calculator/DivideService.java | 28 + .../main/java/calculator/DivideServiceImpl.java | 30 + .../src/main/java/calculator/MultiplyService.java | 28 + .../main/java/calculator/MultiplyServiceImpl.java | 30 + .../src/main/java/calculator/SubtractService.java | 28 + .../main/java/calculator/SubtractServiceImpl.java | 30 + .../src/main/resources/Calculator.composite | 49 ++ .../test/java/calculator/CalculatorTestCase.java | 52 ++ .../sca-java-0.99/samples/chat-webapp/README | 61 ++ .../sca-java-0.99/samples/chat-webapp/build.xml | 159 ++++ .../sca-java-0.99/samples/chat-webapp/pom.xml | 73 ++ .../src/main/java/sample/ChatService.java | 28 + .../src/main/java/sample/ChatServiceImpl.java | 36 + .../chat-webapp/src/main/resources/chat.composite | 40 + .../src/main/webapp/META-INF/sca-contribution.xml | 24 + .../chat-webapp/src/main/webapp/WEB-INF/web.xml | 42 + .../samples/chat-webapp/src/main/webapp/chat.html | 70 ++ .../samples/company-das-webapp/build.xml | 55 ++ .../samples/company-das-webapp/dastest/db.lck | Bin 0 -> 38 bytes .../company-das-webapp/dastest/log/log.ctrl | Bin 0 -> 48 bytes .../company-das-webapp/dastest/log/log1.dat | Bin 0 -> 1048576 bytes .../company-das-webapp/dastest/log/logmirror.ctrl | Bin 0 -> 48 bytes .../company-das-webapp/dastest/seg0/c10.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c101.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c111.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c121.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c130.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c141.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c150.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c161.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c171.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c180.dat | Bin 0 -> 24576 bytes .../company-das-webapp/dastest/seg0/c191.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1a1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1b1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1c0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1d1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1e0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c1f1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c20.dat | Bin 0 -> 24576 bytes .../company-das-webapp/dastest/seg0/c200.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c211.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c221.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c230.dat | Bin 0 -> 86016 bytes .../company-das-webapp/dastest/seg0/c241.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c251.dat | Bin 0 -> 12288 bytes .../company-das-webapp/dastest/seg0/c260.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c271.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c281.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c290.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2a1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2b1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2c1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2d0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2e1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c2f0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c300.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c31.dat | Bin 0 -> 16384 bytes .../company-das-webapp/dastest/seg0/c311.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c320.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c331.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c340.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c351.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c360.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c371.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c380.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c391.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c3a0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c3b1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c3c0.dat | Bin 0 -> 24576 bytes .../company-das-webapp/dastest/seg0/c3d1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c3e0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c3f1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c400.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c41.dat | Bin 0 -> 16384 bytes .../company-das-webapp/dastest/seg0/c411.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c420.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c431.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c440.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c451.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c460.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c471.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c481.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c490.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c4a1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c51.dat | Bin 0 -> 16384 bytes .../company-das-webapp/dastest/seg0/c60.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c71.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c81.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/c90.dat | Bin 0 -> 20480 bytes .../company-das-webapp/dastest/seg0/ca1.dat | Bin 0 -> 24576 bytes .../company-das-webapp/dastest/seg0/cb1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/cc0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/cd1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/ce1.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/seg0/cf0.dat | Bin 0 -> 8192 bytes .../company-das-webapp/dastest/service.properties | 39 + .../samples/company-das-webapp/pom.xml | 86 ++ .../samples/company-das-webapp/readme.html | 199 +++++ .../src/main/java/das/DASService.java | 61 ++ .../src/main/java/das/DASServiceException.java | 37 + .../src/main/java/das/DASServiceImpl.java | 146 ++++ .../src/main/resources/CompanyConfig.xml | 46 ++ .../src/main/resources/dasservice.composite | 34 + .../src/main/resources/log4j.properties | 29 + .../company-das-webapp/src/main/webapp/Company.jsp | 93 +++ .../src/main/webapp/META-INF/context.xml | 25 + .../src/main/webapp/META-INF/sca-contribution.xml | 25 + .../src/main/webapp/WEB-INF/web.xml | 35 + .../sca-java-0.99/samples/company-das/pom.xml | 99 +++ .../sca-java-0.99/samples/company-das/readme.html | 110 +++ .../company-das/src/main/java/das/DASService.java | 61 ++ .../src/main/java/das/DASServiceException.java | 37 + .../src/main/java/das/DASServiceImpl.java | 146 ++++ .../src/main/resources/dasservice.composite | 34 + .../src/test/java/das/DASServiceTestCase.java | 53 ++ .../src/test/resources/CompanyConfig.xml | 52 ++ .../company-das/src/test/resources/dastest/db.lck | Bin 0 -> 38 bytes .../src/test/resources/dastest/log/log.ctrl | Bin 0 -> 48 bytes .../src/test/resources/dastest/log/log1.dat | Bin 0 -> 1048576 bytes .../src/test/resources/dastest/log/logmirror.ctrl | Bin 0 -> 48 bytes .../src/test/resources/dastest/seg0/c10.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c101.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c111.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c121.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c130.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c141.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c150.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c161.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c171.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c180.dat | Bin 0 -> 24576 bytes .../src/test/resources/dastest/seg0/c191.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1a1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1b1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1c0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1d1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1e0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c1f1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c20.dat | Bin 0 -> 24576 bytes .../src/test/resources/dastest/seg0/c200.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c211.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c221.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c230.dat | Bin 0 -> 86016 bytes .../src/test/resources/dastest/seg0/c241.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c251.dat | Bin 0 -> 12288 bytes .../src/test/resources/dastest/seg0/c260.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c271.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c281.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c290.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2a1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2b1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2c1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2d0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2e1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c2f0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c300.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c31.dat | Bin 0 -> 16384 bytes .../src/test/resources/dastest/seg0/c311.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c320.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c331.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c340.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c351.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c360.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c371.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c380.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c391.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c3a0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c3b1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c3c0.dat | Bin 0 -> 24576 bytes .../src/test/resources/dastest/seg0/c3d1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c3e0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c3f1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c400.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c41.dat | Bin 0 -> 16384 bytes .../src/test/resources/dastest/seg0/c411.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c420.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c431.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c440.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c451.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c460.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c471.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c481.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c490.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c4a1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c51.dat | Bin 0 -> 16384 bytes .../src/test/resources/dastest/seg0/c60.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c71.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c81.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/c90.dat | Bin 0 -> 20480 bytes .../src/test/resources/dastest/seg0/ca1.dat | Bin 0 -> 24576 bytes .../src/test/resources/dastest/seg0/cb1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/cc0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/cd1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/ce1.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/seg0/cf0.dat | Bin 0 -> 8192 bytes .../src/test/resources/dastest/service.properties | 39 + .../sca-java-0.99/samples/databinding-echo/README | 143 ++++ .../samples/databinding-echo/build.xml | 75 ++ .../samples/databinding-echo/databinding-echo.png | Bin 0 -> 23907 bytes .../samples/databinding-echo/databinding-echo.svg | 408 ++++++++++ .../sca-java-0.99/samples/databinding-echo/pom.xml | 76 ++ .../src/main/java/dbecho/ComponentAImpl.java | 74 ++ .../src/main/java/dbecho/ComponentBImpl.java | 59 ++ .../src/main/java/dbecho/Echo.java | 32 + .../main/java/dbecho/EchoDataBindingClient.java | 45 ++ .../src/main/java/dbecho/Interface1.java | 32 + .../src/main/java/dbecho/Interface2.java | 36 + .../src/main/resources/EchoDataBinding.composite | 58 ++ .../src/main/resources/wsdl/echo.wsdl | 63 ++ .../test/java/dbecho/EchoDataBindingTestCase.java | 49 ++ .../sca-java-0.99/samples/feed-aggregator/README | 79 ++ .../samples/feed-aggregator/build.xml | 72 ++ .../sca-java-0.99/samples/feed-aggregator/pom.xml | 79 ++ .../src/main/java/feed/AggregatorImpl.java | 100 +++ .../src/main/java/feed/SampleServer.java | 54 ++ .../feed-aggregator/src/main/java/feed/Sort.java | 38 + .../src/main/java/feed/SortImpl.java | 58 ++ .../src/main/resources/FeedAggregator.composite | 60 ++ .../sca-java-0.99/samples/helloworld-dojo/README | 101 +++ .../samples/helloworld-dojo/build-dojo.xml | 91 +++ .../samples/helloworld-dojo/build.xml | 104 +++ .../samples/helloworld-dojo/helloworld-jsonrpc.png | Bin 0 -> 9947 bytes .../samples/helloworld-dojo/helloworld-jsonrpc.svg | 177 ++++ .../sca-java-0.99/samples/helloworld-dojo/pom.xml | 134 +++ .../java/helloworldjsonrpc/HelloWorldService.java | 28 + .../helloworldjsonrpc/HelloWorldServiceImpl.java | 36 + .../src/main/resources/jsonrpc.composite | 37 + .../src/main/webapp/HelloWorldJSONRPC.html | 91 +++ .../src/main/webapp/META-INF/sca-contribution.xml | 26 + .../src/main/webapp/WEB-INF/web.xml | 45 ++ .../helloworld-dojo/src/main/webapp/style.css | 22 + .../samples/helloworld-jsonrpc/README | 90 +++ .../samples/helloworld-jsonrpc/build.xml | 92 +++ .../helloworld-jsonrpc/helloworld-jsonrpc.png | Bin 0 -> 9947 bytes .../helloworld-jsonrpc/helloworld-jsonrpc.svg | 177 ++++ .../samples/helloworld-jsonrpc/pom.xml | 73 ++ .../java/helloworldjsonrpc/HelloWorldService.java | 28 + .../helloworldjsonrpc/HelloWorldServiceImpl.java | 36 + .../src/main/resources/jsonrpc.composite | 37 + .../src/main/webapp/HelloWorldJSONRPC.html | 75 ++ .../src/main/webapp/META-INF/sca-contribution.xml | 26 + .../src/main/webapp/WEB-INF/web.xml | 45 ++ .../helloworld-jsonrpc/src/main/webapp/style.css | 22 + .../samples/helloworld-ws-reference/README | 153 ++++ .../samples/helloworld-ws-reference/build.xml | 72 ++ .../helloworld-ws-reference.png | Bin 0 -> 7549 bytes .../helloworld-ws-reference.svg | 150 ++++ .../samples/helloworld-ws-reference/pom.xml | 79 ++ .../src/main/java/helloworld/HelloWorldClient.java | 38 + .../main/java/helloworld/HelloWorldService.java | 31 + .../helloworld/HelloWorldServiceComponent.java | 42 + .../main/resources/helloworldwsclient.composite | 45 ++ .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 79 ++ .../java/helloworld/HelloWorldClientTestCase.java | 74 ++ .../test/java/helloworld/HelloWorldTestServer.java | 55 ++ .../sca-java-0.99/samples/helloworld-ws-sdo/README | 210 +++++ .../samples/helloworld-ws-sdo/build.xml | 101 +++ .../helloworld-ws-sdo/helloworld-ws-sdo.png | Bin 0 -> 7549 bytes .../helloworld-ws-sdo/helloworld-ws-sdo.svg | 150 ++++ .../samples/helloworld-ws-sdo/pom.xml | 139 ++++ .../src/main/java/helloworld/HelloWorldClient.java | 44 + .../src/main/java/helloworld/HelloWorldImpl.java | 33 + .../src/main/java/helloworld/HelloWorldServer.java | 46 ++ .../main/java/helloworld/HelloWorldService.java | 31 + .../helloworld/HelloWorldServiceComponent.java | 42 + .../src/main/resources/helloworldws.composite | 34 + .../main/resources/helloworldwsclient.composite | 35 + .../src/main/resources/logging.properties | 30 + .../src/main/resources/wsdl/helloworld.wsdl | 88 ++ .../java/helloworld/HelloWorldClientTestCase.java | 69 ++ .../test/java/helloworld/HelloWorldTestServer.java | 55 ++ .../samples/helloworld-ws-service/README | 132 +++ .../samples/helloworld-ws-service/build.xml | 72 ++ .../helloworld-ws-service.png | Bin 0 -> 158 bytes .../helloworld-ws-service.svg | 149 ++++ .../samples/helloworld-ws-service/pom.xml | 79 ++ .../src/main/java/helloworld/HelloWorldImpl.java | 33 + .../src/main/java/helloworld/HelloWorldServer.java | 46 ++ .../main/java/helloworld/HelloWorldService.java | 33 + .../src/main/resources/helloworldws.composite | 33 + .../src/main/resources/wsdl/helloworld.wsdl | 79 ++ .../java/helloworld/HelloWorldServerTestCase.java | 62 ++ .../samples/implementation-composite/README | 116 +++ .../samples/implementation-composite/build.xml | 72 ++ .../implementation-composite.png | Bin 0 -> 47415 bytes .../implementation-composite.svg | 658 +++++++++++++++ .../samples/implementation-composite/pom.xml | 66 ++ .../src/main/java/composite/CompositeClient.java | 41 + .../src/main/java/composite/Source.java | 24 + .../src/main/java/composite/SourceCallback.java | 24 + .../src/main/java/composite/SourceImpl.java | 55 ++ .../src/main/java/composite/Target.java | 30 + .../src/main/java/composite/TargetImpl.java | 41 + .../src/main/resources/InnerComposite.composite | 41 + .../src/main/resources/InnerComposite2.composite | 33 + .../main/resources/META-INF/sca-contribution.xml | 25 + .../src/main/resources/OuterComposite.composite | 39 + .../src/test/java/composite/CompositeTestCase.java | 51 ++ .../samples/implementation-crud-extension/README | 83 ++ .../implementation-crud-extension/build.xml | 51 ++ .../samples/implementation-crud-extension/pom.xml | 77 ++ .../src/main/java/crud/CRUD.java | 54 ++ .../src/main/java/crud/CRUDImplementation.java | 48 ++ .../main/java/crud/CRUDImplementationFactory.java | 37 + .../main/java/crud/backend/ResourceManager.java | 90 +++ .../crud/impl/CRUDImplementationFactoryImpl.java | 47 ++ .../java/crud/impl/CRUDImplementationImpl.java | 117 +++ .../crud/provider/CRUDImplementationInvoker.java | 71 ++ .../crud/provider/CRUDImplementationProvider.java | 71 ++ .../CRUDImplementationProviderFactory.java | 54 ++ .../services/crud.CRUDImplementationFactory | 19 + ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../src/test/java/crud/CRUDTestCase.java | 67 ++ .../src/test/resources/crud.composite | 30 + .../samples/implementation-crud/README | 113 +++ .../samples/implementation-crud/build.xml | 75 ++ .../implementation-crud/implementation-crud.png | Bin 0 -> 4227 bytes .../implementation-crud/implementation-crud.svg | 135 ++++ .../samples/implementation-crud/pom.xml | 64 ++ .../src/main/java/crud/client/CRUDClient.java | 55 ++ .../src/main/resources/crud.composite | 30 + .../src/test/java/crud/client/CRUDTestCase.java | 58 ++ .../samples/implementation-notification/README | 70 ++ .../implementation-notification.png | Bin 0 -> 21543 bytes .../samples/implementation-notification/pom.xml | 75 ++ .../main/java/notification/TestCaseProducer.java | 24 + .../main/java/notification/TrafficAdvisory.java | 24 + .../java/notification/TrafficAdvisoryConsumer.java | 39 + .../java/notification/TrafficAdvisoryProducer.java | 36 + .../java/notification/TrafficAdvisoryTestCase.java | 60 ++ .../TrafficAdvisoryNotification.componentType | 30 + .../TrafficAdvisoryNotification.composite | 50 ++ .../samples/implementation-pojo-extension/README | 70 ++ .../implementation-pojo-extension/build.xml | 51 ++ .../samples/implementation-pojo-extension/pom.xml | 77 ++ .../src/main/java/pojo/POJOImplementation.java | 65 ++ .../main/java/pojo/POJOImplementationFactory.java | 36 + .../pojo/impl/POJOImplementationFactoryImpl.java | 36 + .../java/pojo/impl/POJOImplementationImpl.java | 156 ++++ .../pojo/impl/POJOImplementationProcessor.java | 155 ++++ .../pojo/provider/POJOImplementationInvoker.java | 51 ++ .../pojo/provider/POJOImplementationProvider.java | 98 +++ .../POJOImplementationProviderFactory.java | 45 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../services/pojo.POJOImplementationFactory | 19 + .../src/test/java/helloworld/HelloWorld.java | 26 + .../src/test/java/helloworld/HelloWorldImpl.java | 37 + .../src/test/java/helloworld/HelloWorldImpl2.java | 37 + .../test/java/helloworld/HelloWorldTestCase.java | 50 ++ .../helloworld/HelloWorldImpl2.componentType | 26 + .../test/resources/helloworld/helloworld.composite | 33 + .../sca-java-0.99/samples/loanapplication/pom.xml | 65 ++ .../main/java/loanapplication/LoanApplication.java | 36 + .../loanapplication/LoanApplicationClient.java | 37 + .../src/main/java/loanapplication/LoanClient.java | 29 + .../main/java/loanapplication/LoanClientImpl.java | 64 ++ .../src/main/java/loanapplication/LoanService.java | 43 + .../main/java/loanapplication/LoanServiceImpl.java | 63 ++ .../src/main/resources/loanapplication.composite | 34 + .../loanapplication/LoanApplicationTestCase.java | 83 ++ .../samples/old/bigbank/account/pom.xml | 178 ++++ .../services/account/AccountServiceImpl.java | 279 +++++++ .../services/accountdata/AccountDataService.java | 87 ++ .../accountdata/AccountDataServiceDASImpl.java | 400 +++++++++ .../accountdata/AccountDataServiceImpl.java | 106 +++ .../services/accountdata/CustomerIdService.java | 98 +++ .../account/services/accountdb/AccountDBInit.java | 465 +++++++++++ .../AccountLoggerDataServiceImpl.java | 129 +++ .../accountlogger/AccountLoggerService.java | 47 ++ .../accountlogger/AccountLoggerServiceImpl.java | 216 +++++ .../account/services/stockquote/StockQuote.java | 228 ++++++ .../services/stockquote/StockQuoteService.java | 31 + .../services/stockquote/StockQuoteServiceImpl.java | 68 ++ .../StockQuoteWebservicexServiceImpl.java | 153 ++++ .../src/main/resources/DasAccountConfiguration.xml | 79 ++ .../src/main/resources/wsdl/AccountService.wsdl | 467 +++++++++++ .../resources/wsdl/stockquotes.webservicex.wsdl | 136 ++++ .../account/src/main/webapp/WEB-INF/default.scdl | 80 ++ .../account/src/main/webapp/WEB-INF/web.xml | 70 ++ .../java/bigbank/account/client/AccountClient.java | 56 ++ .../samples/old/bigbank/docs/Show.Image.html | 40 + .../samples/old/bigbank/docs/accountfiles.png | Bin 0 -> 15889 bytes .../samples/old/bigbank/docs/accountmodule.png | Bin 0 -> 33300 bytes .../samples/old/bigbank/docs/modualoverview.png | Bin 0 -> 6074 bytes .../samples/old/bigbank/docs/webclientfiles.png | Bin 0 -> 17123 bytes .../samples/old/bigbank/docs/webclientmodule.png | Bin 0 -> 10748 bytes .../sca-java-0.99/samples/old/bigbank/pom.xml | 44 + .../sca-java-0.99/samples/old/bigbank/readme.html | 894 +++++++++++++++++++++ .../samples/old/bigbank/webclient/pom.xml | 167 ++++ .../account/AccountServiceComponentImpl.java | 117 +++ .../services/profile/AccountLoginServiceImpl.java | 64 ++ .../webclient/services/profile/LoginService.java | 36 + .../webclient/services/profile/ProfileService.java | 42 + .../services/profile/ProfileServiceImpl.java | 69 ++ .../services/profile/SimpleLoginServiceImpl.java | 51 ++ .../webclient/tags/account/AccountLogTag.java | 120 +++ .../webclient/tags/account/AccountStatusTag.java | 135 ++++ .../webclient/tags/account/StockLogTag.java | 81 ++ .../webclient/tags/account/StockStatusTag.java | 85 ++ .../webclient/tags/sca/LoginBarrierTag.java | 101 +++ .../bigbank/webclient/tags/sca/ServiceTag.java | 107 +++ .../java/bigbank/webclient/ui/FormServlet.java | 161 ++++ .../java/bigbank/webclient/ui/LoginServlet.java | 96 +++ .../src/main/resources/wsdl/AccountService.wsdl | 466 +++++++++++ .../webclient/src/main/webapp/CustomerProfile.jsp | 100 +++ .../src/main/webapp/WEB-INF/bigbank-tags.tld | 127 +++ .../webclient/src/main/webapp/WEB-INF/default.scdl | 53 ++ .../webclient/src/main/webapp/WEB-INF/web.xml | 83 ++ .../webclient/src/main/webapp/accountLog.jsp | 99 +++ .../src/main/webapp/accountTransaction.jsp | 50 ++ .../bigbank/webclient/src/main/webapp/login.html | 60 ++ .../webclient/src/main/webapp/purchaseStock.jsp | 59 ++ .../webclient/src/main/webapp/stockSale.jsp | 56 ++ .../bigbank/webclient/src/main/webapp/summary.jsp | 144 ++++ .../webclient/client/TestAccountService.java | 45 ++ .../bigbank/webclient/client/TestLoginService.java | 42 + .../samples/old/binding-echo2-extension/README | 77 ++ .../samples/old/binding-echo2-extension/build.xml | 51 ++ .../samples/old/binding-echo2-extension/pom.xml | 78 ++ .../src/main/java/echo2/extension/EchoBinding.java | 60 ++ .../java/echo2/extension/EchoBindingInvoker.java | 44 + .../extension/EchoBindingProviderFactory.java | 56 ++ .../extension/EchoReferenceBindingProvider.java | 60 ++ .../extension/EchoServiceBindingProvider.java | 73 ++ .../src/main/java/echo2/server/EchoServer.java | 78 ++ .../java/echo2/server/EchoServiceListener.java | 55 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...che.tuscany.sca.provider.BindingProviderFactory | 19 + .../src/test/java/echo2/Echo.java | 29 + .../src/test/java/echo2/EchoComponentImpl.java | 44 + .../src/test/java/echo2/EchoReferenceTestCase.java | 50 ++ .../src/test/java/echo2/EchoServiceTestCase.java | 50 ++ .../src/test/resources/EchoBinding.composite | 40 + .../old/implementation-crud2-extension/README | 87 ++ .../old/implementation-crud2-extension/build.xml | 51 ++ .../old/implementation-crud2-extension/pom.xml | 77 ++ .../src/main/java/crud2/CRUD.java | 54 ++ .../main/java/crud2/backend/ResourceManager.java | 90 +++ .../java/crud2/extension/CRUDImplementation.java | 128 +++ .../crud2/extension/CRUDImplementationInvoker.java | 70 ++ .../extension/CRUDImplementationProvider.java | 69 ++ .../CRUDImplementationProviderFactory.java | 49 ++ ...ca.contribution.processor.StAXArtifactProcessor | 19 + ...cany.sca.provider.ImplementationProviderFactory | 19 + .../src/test/java/crud2/CRUDTestCase.java | 68 ++ .../src/test/resources/crud2.composite | 30 + .../samples/osgi-supplychain/build-bundles.xml | 32 + .../sca-java-0.99/samples/osgi-supplychain/pom.xml | 187 +++++ .../samples/osgi-supplychain/readme.htm | 332 ++++++++ .../src/main/java/supplychain/OSGiBundleImpl.java | 123 +++ .../main/java/supplychain/SupplyChainClient.java | 43 + .../main/java/supplychain/customer/Customer.java | 33 + .../customer/JavaCustomerComponentImpl.java | 51 ++ .../customer/OSGiCustomerComponentImpl.java | 52 ++ .../supplychain/customer/OSGiCustomerImpl.java | 48 ++ .../retailer/JavaRetailerComponentImpl.java | 54 ++ .../retailer/OSGiRetailerComponentImpl.java | 47 ++ .../supplychain/retailer/OSGiRetailerImpl.java | 46 ++ .../main/java/supplychain/retailer/Retailer.java | 28 + .../shipper/JavaShipperComponentImpl.java | 48 ++ .../shipper/OSGiShipperComponentImpl.java | 46 ++ .../java/supplychain/shipper/OSGiShipperImpl.java | 43 + .../src/main/java/supplychain/shipper/Shipper.java | 28 + .../warehouse/JavaWarehouseComponentImpl.java | 49 ++ .../warehouse/OSGiWarehouseComponentImpl.java | 49 ++ .../supplychain/warehouse/OSGiWarehouseImpl.java | 46 ++ .../main/java/supplychain/warehouse/Warehouse.java | 28 + .../src/main/resources/Customer.componentType | 28 + .../src/main/resources/META-INF/LICENSE.txt | 202 +++++ .../src/main/resources/META-INF/NOTICE | 14 + .../src/main/resources/META-INF/README.txt | 35 + .../src/main/resources/Retailer.componentType | 28 + .../src/main/resources/Shipper.componentType | 28 + .../src/main/resources/Warehouse.componentType | 28 + .../src/main/resources/osgi/Customer.mf | 11 + .../src/main/resources/osgi/Retailer.mf | 10 + .../src/main/resources/osgi/Shipper.mf | 10 + .../src/main/resources/osgi/Warehouse.mf | 10 + .../src/main/resources/osgi/ds/Customer.mf | 10 + .../src/main/resources/osgi/ds/Customer.xml | 33 + .../src/main/resources/osgi/ds/Retailer.mf | 11 + .../src/main/resources/osgi/ds/Retailer.xml | 33 + .../src/main/resources/osgi/ds/Shipper.mf | 10 + .../src/main/resources/osgi/ds/Shipper.xml | 34 + .../src/main/resources/osgi/ds/Warehouse.mf | 11 + .../src/main/resources/osgi/ds/Warehouse.xml | 33 + .../src/main/resources/supplychain.composite | 66 ++ .../src/main/resources/supplychain.ds.composite | 66 ++ .../supplychain/SupplyChainClientTestCase.java | 63 ++ .../branches/sca-java-0.99/samples/pom.xml | 80 ++ .../sca-java-0.99/samples/quote-xquery/pom.xml | 168 ++++ .../java/xquery/quote/AvailQuoteProviderImpl.java | 30 + .../xquery/quote/AvailQuoteProviderNodeInfo.java | 30 + .../xquery/quote/AvailQuoteProviderService.java | 29 + .../xquery/quote/ExternalReferencesQuoteJoin.java | 29 + .../main/java/xquery/quote/PriceQuoteProvider.java | 30 + .../java/xquery/quote/PriceQuoteProviderImpl.java | 27 + .../xquery/quote/PriceQuoteProviderNodeInfo.java | 30 + .../java/xquery/quote/PropertiesQuoteJoin.java | 29 + .../main/java/xquery/quote/QuoteCalculator.java | 28 + .../java/xquery/quote/QuoteCalculatorImpl.java | 42 + .../src/main/java/xquery/quote/QuoteJoin.java | 31 + .../src/main/java/xquery/quote/QuoteJoinLocal.java | 31 + .../main/java/xquery/quote/QuoteJoinLocalImpl.java | 67 ++ .../src/main/java/xquery/quote/TestHelper.java | 144 ++++ .../src/main/resources/META-INF/sca/quote_join.xq | 37 + .../META-INF/sca/quote_join_external_references.xq | 49 ++ .../META-INF/sca/quote_join_properties.xq | 48 ++ .../src/main/resources/wsdl/AvailQuote.xsd | 39 + .../src/main/resources/wsdl/PriceQuote.xsd | 49 ++ .../quote-xquery/src/main/resources/wsdl/Quote.xsd | 40 + .../main/resources/wsdl/availquoteprovider.wsdl | 80 ++ .../src/main/resources/wsdl/quotejoin.wsdl | 89 ++ .../src/main/resources/xqueryquotews.composite | 49 ++ .../main/resources/xqueryquotewsclient.composite | 108 +++ .../xquery/quote/XQueryQuoteClientTestCase.java | 145 ++++ .../java/xquery/quote/XQueryQuoteTestServer.java | 50 ++ .../samples/simple-bigbank-spring/README | 91 +++ .../samples/simple-bigbank-spring/build.xml | 72 ++ .../samples/simple-bigbank-spring/pom.xml | 72 ++ .../simple-bigbank-spring.png | Bin 0 -> 10202 bytes .../simple-bigbank-spring.svg | 200 +++++ .../main/java/bigbank/account/AccountReport.java | 43 + .../main/java/bigbank/account/AccountService.java | 26 + .../java/bigbank/account/AccountServiceImpl.java | 85 ++ .../src/main/java/bigbank/accountdata/Account.java | 26 + .../bigbank/accountdata/AccountDataService.java | 28 + .../accountdata/AccountDataServiceImpl.java | 54 ++ .../java/bigbank/accountdata/CheckingAccount.java | 35 + .../java/bigbank/accountdata/SavingsAccount.java | 35 + .../java/bigbank/accountdata/StockAccount.java | 43 + .../main/java/bigbank/client/BigBankClient.java | 43 + .../java/bigbank/stockquote/StockQuoteImpl.java | 36 + .../java/bigbank/stockquote/StockQuoteService.java | 31 + .../src/main/resources/Account-spring-context.xml | 42 + .../src/main/resources/BigBank.composite | 35 + .../src/main/resources/StockQuote.composite | 30 + .../src/test/java/bigbank/BigBankTestCase.java | 50 ++ .../sca-java-0.99/samples/simple-bigbank/README | 91 +++ .../sca-java-0.99/samples/simple-bigbank/build.xml | 72 ++ .../sca-java-0.99/samples/simple-bigbank/pom.xml | 65 ++ .../samples/simple-bigbank/simple-bigbank.png | Bin 0 -> 10202 bytes .../samples/simple-bigbank/simple-bigbank.svg | 200 +++++ .../main/java/bigbank/account/AccountReport.java | 43 + .../main/java/bigbank/account/AccountService.java | 26 + .../java/bigbank/account/AccountServiceImpl.java | 68 ++ .../src/main/java/bigbank/accountdata/Account.java | 26 + .../bigbank/accountdata/AccountDataService.java | 28 + .../accountdata/AccountDataServiceImpl.java | 54 ++ .../java/bigbank/accountdata/CheckingAccount.java | 35 + .../java/bigbank/accountdata/SavingsAccount.java | 35 + .../java/bigbank/accountdata/StockAccount.java | 43 + .../main/java/bigbank/client/BigBankClient.java | 43 + .../java/bigbank/stockquote/StockQuoteImpl.java | 36 + .../java/bigbank/stockquote/StockQuoteService.java | 32 + .../src/main/resources/Account.composite | 38 + .../src/main/resources/BigBank.composite | 35 + .../src/main/resources/StockQuote.composite | 31 + .../src/test/java/bigbank/BigBankTestCase.java | 50 ++ .../samples/simple-callback-ws/README | 134 +++ .../samples/simple-callback-ws/build.xml | 72 ++ .../samples/simple-callback-ws/pom.xml | 79 ++ .../simple-callback-ws/simple-callback-ws.png | Bin 0 -> 137 bytes .../simple-callback-ws/simple-callback-ws.svg | 150 ++++ .../src/main/java/simplecallback/MyClient.java | 27 + .../src/main/java/simplecallback/MyClientImpl.java | 51 ++ .../src/main/java/simplecallback/MyService.java | 34 + .../java/simplecallback/MyServiceCallback.java | 30 + .../main/java/simplecallback/MyServiceImpl.java | 54 ++ .../java/simplecallback/SimpleCallbackClient.java | 38 + .../src/main/resources/simplecallback.composite | 49 ++ .../src/main/resources/wsdl/simplecallback.wsdl | 103 +++ .../simplecallback/SimpleCallbackTestCase.java | 53 ++ .../sca-java-0.99/samples/simple-callback/README | 97 +++ .../samples/simple-callback/build.xml | 72 ++ .../sca-java-0.99/samples/simple-callback/pom.xml | 65 ++ .../samples/simple-callback/simple-callback.png | Bin 0 -> 137 bytes .../samples/simple-callback/simple-callback.svg | 150 ++++ .../src/main/java/simplecallback/MyClient.java | 27 + .../src/main/java/simplecallback/MyClientImpl.java | 49 ++ .../src/main/java/simplecallback/MyService.java | 32 + .../java/simplecallback/MyServiceCallback.java | 27 + .../main/java/simplecallback/MyServiceImpl.java | 51 ++ .../java/simplecallback/SimpleCallbackClient.java | 38 + .../src/main/resources/simplecallback.composite | 34 + .../simplecallback/SimpleCallbackTestCase.java | 51 ++ .../samples/spi-implementation-pojo/pom.xml | 59 ++ .../src/main/java/sample/JavaImplementation.java | 35 + .../java/sample/JavaImplementationActivator.java | 37 + .../src/main/java/sample/JavaInvoker.java | 59 ++ .../src/main/java/sample/JavaInvokerFactory.java | 47 ++ ....apache.tuscany.sca.spi.ImplementationActivator | 18 + .../src/test/java/helloworld/HelloWorld.java | 26 + .../src/test/java/helloworld/HelloWorldImpl.java | 28 + .../test/java/helloworld/HelloWorldTestCase.java | 35 + .../test/resources/helloworld/helloworld.composite | 28 + .../sca-java-0.99/samples/supplychain/README | 101 +++ .../sca-java-0.99/samples/supplychain/build.xml | 72 ++ .../sca-java-0.99/samples/supplychain/pom.xml | 65 ++ .../src/main/java/supplychain/Customer.java | 33 + .../java/supplychain/CustomerComponentImpl.java | 44 + .../src/main/java/supplychain/Retailer.java | 28 + .../java/supplychain/RetailerComponentImpl.java | 39 + .../src/main/java/supplychain/Shipper.java | 28 + .../java/supplychain/ShipperComponentImpl.java | 39 + .../main/java/supplychain/SupplyChainClient.java | 40 + .../src/main/java/supplychain/Warehouse.java | 28 + .../java/supplychain/WarehouseComponentImpl.java | 39 + .../src/main/resources/supplychain.composite | 45 ++ .../supplychain/SupplyChainClientTestCase.java | 52 ++ .../samples/supplychain/supplychain.png | Bin 0 -> 3898 bytes .../samples/supplychain/supplychain.svg | 228 ++++++ .../sca-java-0.99/samples/web-resource/README | 72 ++ .../sca-java-0.99/samples/web-resource/build.xml | 65 ++ .../sca-java-0.99/samples/web-resource/pom.xml | 79 ++ .../src/main/java/web/resource/SampleServer.java | 44 + .../src/main/resources/WebResource.composite | 32 + .../src/main/resources/myContent/index.html | 49 ++ 832 files changed, 44140 insertions(+) create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/EchoBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/definitions.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoBindingClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/resources/EchoBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/binding-notification-broker.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/binding-notification-consumer.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/binding-notification-producer.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/wsdl/TrafficAdvisory.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/CalculatorNode.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/DomainNode.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/domain.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/management.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/wsdl/add.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/calc.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/resources/Calculator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/test/java/calculator/CalculatorTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/resources/chat.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/chat.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/db.lck create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log.ctrl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/logmirror.ctrl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c10.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c101.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c111.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c121.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c130.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c141.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c150.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c161.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c171.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c180.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c191.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1c0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1d1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1e0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1f1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c20.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c200.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c211.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c221.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c230.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c241.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c251.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c260.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c271.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c281.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c290.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2c1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2d0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2e1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2f0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c300.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c31.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c311.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c320.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c331.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c340.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c351.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c360.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c371.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c380.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c391.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3a0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3c0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3d1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3e0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3f1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c400.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c41.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c411.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c420.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c431.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c440.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c451.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c460.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c471.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c481.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c490.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c4a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c51.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c60.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c71.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c81.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c90.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ca1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cb1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cc0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cd1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ce1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cf0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/service.properties create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/readme.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceException.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/CompanyConfig.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/dasservice.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/log4j.properties create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/Company.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/context.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/readme.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceException.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/resources/dasservice.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/java/das/DASServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/CompanyConfig.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/db.lck create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log.ctrl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/logmirror.ctrl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c10.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c101.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c111.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c121.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c130.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c141.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c150.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c161.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c171.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c180.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c191.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1c0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1d1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1e0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1f1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c20.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c200.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c211.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c221.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c230.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c241.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c251.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c260.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c271.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c281.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c290.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2c1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2d0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2e1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2f0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c300.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c31.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c311.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c320.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c331.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c340.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c351.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c360.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c371.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c380.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c391.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3a0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3b1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3c0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3d1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3e0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3f1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c400.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c41.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c411.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c420.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c431.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c440.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c451.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c460.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c471.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c481.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c490.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c4a1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c51.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c60.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c71.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c81.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c90.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ca1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cb1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cc0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cd1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ce1.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cf0.dat create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/service.properties create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface1.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface2.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/EchoDataBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SampleServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/Sort.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SortImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/resources/FeedAggregator.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build-dojo.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/style.css create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/style.css create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/logging.properties create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/helloworldws.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/CompositeClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Source.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Target.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/TargetImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite2.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/OuterComposite.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUD.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/resources/crud.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/resources/crud.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/implementation-notification.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/resources/loanapplication.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/DasAccountConfiguration.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/default.scdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/Show.Image.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountfiles.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountmodule.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/modualoverview.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientfiles.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientmodule.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/readme.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/CustomerProfile.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/web.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountLog.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountTransaction.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/login.html create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/purchaseStock.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/stockSale.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/summary.jsp create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBinding.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoReferenceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoServiceBindingProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServiceListener.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/Echo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoReferenceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoServiceTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/resources/EchoBinding.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/build-bundles.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/readme.htm create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Customer.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/LICENSE.txt create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/NOTICE create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/README.txt create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Retailer.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Shipper.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Warehouse.componentType create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/TestHelper.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join.xq create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/availquoteprovider.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotews.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/Account.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/CheckingAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/SavingsAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/StockAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/Account-spring-context.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/Account.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/BigBank.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/StockQuote.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyService.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/resources/simplecallback.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Customer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Retailer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Shipper.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Warehouse.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/resources/supplychain.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.png create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.svg create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/README create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/build.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/pom.xml create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/java/web/resource/SampleServer.java create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/WebResource.composite create mode 100644 sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/myContent/index.html (limited to 'sca-java-1.x/branches/sca-java-0.99/samples') diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/README b/sca-java-1.x/branches/sca-java-0.99/samples/README new file mode 100644 index 0000000000..67c84f3c37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/README @@ -0,0 +1,271 @@ +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 the 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. This list is ordered in a rough +order of increasing complexity. + +calculator - A calculator built with java components and local + wires +calculator-script - The calculator but this time built using various + script languages +calculator-webapp - The calculator again but this time running inside a + web app +chat-webapp - A simple chat style web app demonsrating how to use + the AJAX binding +feed-aggregator - Demonstrates using the ATOM binding +helloworld-ws-reference - The client side of a hello world sample that uses a + web service binding +helloworld-ws-service - The server side of a hello world sample that uses a + web service binding +helloworld-ws-sdo - helloworld using ws binding and SDO +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 +helloworld-jsonrpc - An SCA application that exposes a service using + JSONRPC +helloworld-dojo - An SCA application that exposes a service using + JSONRPC and a client using the Dojo toolkit +simple-callback - An SCA application with two components demonstrating + the callback interface +simple-callback-ws - An SCA application with two components demonstrating + the callback interface across the Web service binding +implementation-composite - An SCA application that shows how composites are used to + implement components +supplychain - A more complicated sample showing how asynchronous + callbacks can be used +osgi-supplychain - the supplychain sample showing OSGi integration with + SCA components using OSGi bundles +databinding-echo - An SCA application that shows how databindings + transform data +simple-bigbank - A banking application built with java components + and local wires +binding-notification-* - A set of samples demonstrating Tuscany's support +implementation-notification for PUB/SUB interactions + +calculator-distributed - Demonstrates distributed SCA domains with calculator + components running in multiple JVMs + +There are two samples that demonstrate how to build extensions for the +Tuscany SCA runtime. These samples are slightly different from the samples +above in that the provided code is concerned with building the extension +and not with building an application that uses it. The application +that shows how the new extension can be used is provided in an associated +sample. + +implementation-crud-extension - Shows how to build new implementation type + extensions +implementation-crud - A sample application that exercises the new + implementation extensions +binding-echo-extension - Shows how to build new binding extensions +binding-echo - A sample application that exercises the new + binding extension + +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.0 - if you are going to use Ant +Apache Maven 2.0.6 - 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 ..\..\lib\tuscany-sca-manifest.jar;target\ + +for example : java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient + +on *nix + +java -cp ../../lib/tuscany-sca-manifest.jar:target/ + +for example : java -cp ../../lib/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 ..\..\lib\tuscany-sca-manifest.jar;target\classes + +for example : java -cp ..\..\lib\tuscany-sca-manifest.jar;target\classes calculator.CalculatorClient + +on *nix + +java -cp ../../lib/tuscany-sca-manifest.jar:target/classes + +for example : java -cp ../../lib/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 eclipse:eclipse + +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-0.90-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 all of the jars provided in + lib + 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/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/README b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/README new file mode 100644 index 0000000000..94716b151f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/README @@ -0,0 +1,74 @@ +Binding Echo Sample +=================== +This sample demonstrates how new bindings are constructed for Apache Tuscany +SCA. + +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 want to try out the echo binding that this sample provides +please see the binding-echo sample that provides the necessary client and +application code to bring up an application that uses this binding + +Sample Overview +--------------- +This sample contains a implementation of an SCA binding that simply echoes back +any messages that are sent to it. + +binding-echo-extension/ + src/ + main/ + java/ + echo/ - The binding interfaces + impl/ - The bindings model classes + provider/ - The bindings runtime classes + server/ - A dummy server that the binding is plugged into + resources/ + META-INF/ + services/ - The extension declaration + test/ + java/ + echo/ - test code + resources/ + EchoBinding.composite - the SCA assembly used by the unit test + build.xml - the Ant build file + pom.xml - the Maven build file + +Building The Sample Using Ant +----------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd binding-echo-extension +ant compile + +See the binding-echo sample to run a sample that uses this binding. + +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 binding-echo-extension +mvn + +Maven will also test that the sample extension built properly. You should see +the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running echo.EchoServiceTestCase +Returned message: oof +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.011 sec +Running echo.EchoReferenceTestCase +Returned message: oof +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.06 sec + +Results : + +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/build.xml new file mode 100644 index 0000000000..5df5981bea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/pom.xml new file mode 100644 index 0000000000..2c7dd5cbc5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-echo-extension + Apache Tuscany Echo Binding Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBinding.java new file mode 100644 index 0000000000..16948874d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBinding.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 echo; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +/** + * A model for the sample Echo binding. + */ +public interface EchoBinding extends Binding, PolicySetAttachPoint { + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.java new file mode 100644 index 0000000000..0f6fee82be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/EchoBindingFactory.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 echo; + +/** + * A factory for the sample Echo binding model. + */ +public interface EchoBindingFactory { + + /** + * Creates a new Echo binding. + * + * @return a new Echo binding + */ + EchoBinding createEchoBinding(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.java new file mode 100644 index 0000000000..af759dbf93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingFactoryImpl.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 echo.impl; + +import echo.EchoBinding; +import echo.EchoBindingFactory; + +/** + * A factory for the sample Echo binding model. + */ +public class EchoBindingFactoryImpl implements EchoBindingFactory { + + public EchoBinding createEchoBinding() { + return new EchoBindingImpl(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java new file mode 100644 index 0000000000..bf91880f76 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingImpl.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPointType; +import org.apache.tuscany.sca.policy.PolicySet; + +import echo.EchoBinding; + +/** + * Implementation of the Echo binding model. + */ +public class EchoBindingImpl implements EchoBinding { + + private String name; + private String uri; + private List requiredIntents = new ArrayList(); + private List policySets = new ArrayList(); + private IntentAttachPointType bindingType = null; + + public IntentAttachPointType getType() { + return bindingType; + } + + public void setType(IntentAttachPointType type) { + this.bindingType = type; + } + + public String getName() { + return name; + } + + public String getURI() { + return uri; + } + + public void setName(String name) { + this.name = name; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public List getPolicySets() { + return policySets; + } + + public List getRequiredIntents() { + return requiredIntents; + } + + public boolean isUnresolved() { + // The sample binding is always resolved + return false; + } + + public void setUnresolved(boolean unresolved) { + // The sample binding is always resolved + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java new file mode 100644 index 0000000000..cd6ad97193 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/impl/EchoBindingProcessor.java @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.IntentAttachPoint; +import org.apache.tuscany.sca.policy.PolicyFactory; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; + +import echo.EchoBinding; +import echo.EchoBindingFactory; + +/** + * A processor for elements. + */ +public class EchoBindingProcessor implements StAXArtifactProcessor { + + private QName BINDING_ECHO = new QName("http://echo", "binding.echo"); + + private final EchoBindingFactory factory; + private PolicyFactory policyFactory; + + public EchoBindingProcessor(EchoBindingFactory factory, PolicyFactory pFactory) { + this.factory = factory; + this.policyFactory = pFactory; + } + + public QName getArtifactType() { + return BINDING_ECHO; + } + + public Class getModelType() { + return EchoBinding.class; + } + + public EchoBinding read(XMLStreamReader reader) throws ContributionReadException { + EchoBinding echoBinding = factory.createEchoBinding(); + + String name = reader.getAttributeValue(null, "name"); + if (name != null) { + echoBinding.setName(name); + } + String uri = reader.getAttributeValue(null, "uri"); + if (uri != null) { + echoBinding.setURI(uri); + } + + readPolicies(echoBinding, null, reader); + return echoBinding; + } + + protected QName getQNameValue(XMLStreamReader reader, String value) { + if (value != null) { + int index = value.indexOf(':'); + String prefix = index == -1 ? "" : value.substring(0, index); + String localName = index == -1 ? value : value.substring(index + 1); + String ns = reader.getNamespaceContext().getNamespaceURI(prefix); + if (ns == null) { + ns = ""; + } + return new QName(ns, localName, prefix); + } else { + return null; + } + } + + protected void readIntents(IntentAttachPoint attachPoint, Operation operation, XMLStreamReader reader) { + String value = reader.getAttributeValue(null, "requires"); + if (value != null) { + List requiredIntents = attachPoint.getRequiredIntents(); + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + QName qname = getQNameValue(reader, tokens.nextToken()); + Intent intent = policyFactory.createIntent(); + intent.setName(qname); + if (operation != null) { + //intent.getOperations().add(operation); + } + requiredIntents.add(intent); + } + } + } + + protected void readPolicies(PolicySetAttachPoint attachPoint, Operation operation, XMLStreamReader reader) { + readIntents(attachPoint, operation, reader); + + String value = reader.getAttributeValue(null, "policySets"); + if (value != null) { + List policySets = attachPoint.getPolicySets(); + for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) { + QName qname = getQNameValue(reader, tokens.nextToken()); + PolicySet policySet = policyFactory.createPolicySet(); + policySet.setName(qname); + if (operation != null) { + //policySet.getOperations().add(operation); + } + policySets.add(policySet); + } + } + } + + public void write(EchoBinding echoBinding, XMLStreamWriter writer) throws ContributionWriteException { + } + + public void resolve(EchoBinding echoBinding, ModelResolver resolver) throws ContributionResolveException { + List requiredIntents = new ArrayList(); + Intent resolvedIntent = null; + for ( Intent intent : echoBinding.getRequiredIntents() ) { + resolvedIntent = resolver.resolveModel(Intent.class, intent); + requiredIntents.add(resolvedIntent); + } + echoBinding.getRequiredIntents().clear(); + echoBinding.getRequiredIntents().addAll(requiredIntents); + + List resolvedPolicySets = new ArrayList(); + PolicySet resolvedPolicySet = null; + for ( PolicySet policySet : echoBinding.getPolicySets() ) { + resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet); + resolvedPolicySets.add(resolvedPolicySet); + } + echoBinding.getPolicySets().clear(); + echoBinding.getPolicySets().addAll(resolvedPolicySets); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.java new file mode 100644 index 0000000000..91697fcd9a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingInvoker.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 echo.provider; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Invoker for the sample echo binding. + */ +class EchoBindingInvoker implements Invoker { + + EchoBindingInvoker() { + } + + public Message invoke(Message msg) { + try { + System.out.println("Passing thro invoker..."); + Object[] args = msg.getBody(); + + // echo back the first parameter, a real binding would invoke some API for flowing the request + Object result = args[0]; + + msg.setBody(result); + + } catch (Exception e) { + msg.setFaultBody(e); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java new file mode 100644 index 0000000000..485386cea8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingPoliciedInvoker.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.policy.PolicySet; + +import echo.provider.policy.PolicyHandler; +import echo.provider.policy.EncryptionPolicyHandler; + +/** + * Invoker that applies policies before invocation for the sample echo binding. + */ +public class EchoBindingPoliciedInvoker implements Invoker { + List policies = null; + Map policyHandlers = new HashMap(); + + public EchoBindingPoliciedInvoker(List policies) { + this.policies = policies; + policyHandlers.put(new QName("http://sample/policy","EncryptionPolicy"), + new EncryptionPolicyHandler()); + } + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + + applyPolicies(args); + + // echo back the first parameter, a real binding would invoke some API for flowing the request + Object result = args[0]; + + msg.setBody(result); + + } catch (Exception e) { + msg.setFaultBody(e); + } + return msg; + } + + private void applyPolicies(Object[] args) throws Exception { + for ( PolicySet policySet : policies ) { + PolicyHandler policyHandler = policyHandlers.get(policySet.getName()); + policyHandler.applyPolicy(args, policySet); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java new file mode 100644 index 0000000000..ba74d8f99a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoBindingProviderFactory.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.provider; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +import echo.EchoBinding; + + +/** + * Implementation of the Echo binding model. + */ +public class EchoBindingProviderFactory implements BindingProviderFactory { + + private MessageFactory messageFactory; + + public EchoBindingProviderFactory(ExtensionPointRegistry extensionPoints) { + ModelFactoryExtensionPoint factories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + this.messageFactory = factories.getFactory(MessageFactory.class); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, EchoBinding binding) { + return new EchoReferenceBindingProvider(component, reference, binding); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, EchoBinding binding) { + return new EchoServiceBindingProvider(component, service, binding, messageFactory); + } + + public Class getModelType() { + return EchoBinding.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java new file mode 100644 index 0000000000..06c8df0080 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoReferenceBindingProvider.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.provider; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.policy.Intent; +import org.apache.tuscany.sca.policy.PolicySet; +import org.apache.tuscany.sca.policy.PolicySetAttachPoint; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +import echo.EchoBinding; + +/** + * Implementation of the Echo binding provider. + */ +class EchoReferenceBindingProvider implements ReferenceBindingProvider { + + private RuntimeComponentReference reference; + private EchoBinding binding; + + EchoReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + EchoBinding binding) { + this.reference = reference; + this.binding = binding; + } + + public Invoker createInvoker(Operation operation, boolean isCallback) { + if (isCallback) { + throw new UnsupportedOperationException(); + } else { + if ( !binding.getPolicySets().isEmpty() ){ + return new EchoBindingPoliciedInvoker(((PolicySetAttachPoint)binding).getPolicySets()); + } else { + return new EchoBindingInvoker(); + } + } + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java new file mode 100644 index 0000000000..43354d1e90 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/EchoServiceBindingProvider.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.provider; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +import echo.EchoBinding; +import echo.server.EchoServer; +import echo.server.EchoServiceListener; + +/** + * Implementation of the Echo binding provider. + */ +class EchoServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeComponent component; + private RuntimeComponentService service; + private EchoBinding binding; + private MessageFactory messageFactory; + + EchoServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, EchoBinding binding, MessageFactory messageFactory) { + this.component = component; + this.service = service; + this.binding = binding; + this.messageFactory = messageFactory; + } + + public InterfaceContract getBindingInterfaceContract() { + return service.getInterfaceContract(); + } + + public void start() { + + RuntimeComponentService componentService = (RuntimeComponentService) service; + RuntimeWire wire = componentService.getRuntimeWire(binding); + InvocationChain chain = wire.getInvocationChains().get(0); + + // Register with the hosting server + String uri = binding.getURI(); + EchoServer.getServer().register(uri, new EchoServiceListener(chain.getHeadInvoker(), messageFactory)); + } + + public void stop() { + + // Unregister from the hosting server + String uri = component.getURI() + "/" + binding.getName(); + EchoServer.getServer().unregister(uri); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.java new file mode 100644 index 0000000000..33dc761aa4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicy.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 echo.provider.policy; + +/** + */ +public class EchoBindingEncryptionPolicy extends EchoBindingPolicy { + + private String encryptionStrategyClassName; + private Class strategyClass; + + public String getEncryptionStrategyClassName() { + return encryptionStrategyClassName; + } + public void setEncryptionStrategyClassName(String encryptionStrategyClassName) { + this.encryptionStrategyClassName = encryptionStrategyClassName; + } + public Class getStrategyClass() { + return strategyClass; + } + public void setStrategyClass(Class strategy) { + this.strategyClass = strategy; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.java new file mode 100644 index 0000000000..49d195395b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingEncryptionPolicyProcessor.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 echo.provider.policy; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; + + +/** + * + */ +public class EchoBindingEncryptionPolicyProcessor extends EchoBindingPolicyProcessor { + + public EchoBindingEncryptionPolicyProcessor(ModelFactoryExtensionPoint modelFactories) { + } + + public Class getModelType() { + return EchoBindingEncryptionPolicy.class; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java new file mode 100644 index 0000000000..7d38e3b7a8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicy.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.Policy; + +/** + + */ +public class EchoBindingPolicy implements Policy { + private boolean unresolved = true; + + public QName getSchemaName() { + return new QName("http://sample/policy","echoBindingPolicy"); + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java new file mode 100644 index 0000000000..72b8002238 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EchoBindingPolicyProcessor.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ClassReference; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; + +/** + * + */ +public abstract class EchoBindingPolicyProcessor implements StAXArtifactProcessor { + public static final String ENCRYPTION = "Encryption"; + + public QName getArtifactType() { + return new QName("http://sample/policy", "echoBindingPolicy"); + } + + public T read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + String name = reader.getAttributeValue(null, "name"); + if (name != null && name.equals(ENCRYPTION)) { + EchoBindingEncryptionPolicy policy = new EchoBindingEncryptionPolicy(); + policy.setEncryptionStrategyClassName(reader.getAttributeValue(null, "strategy")); + return (T)policy; + } + return null; + } + + public void write(T arg0, XMLStreamWriter arg1) throws ContributionWriteException, XMLStreamException { + } + + public void resolve(T policy, ModelResolver resolver) throws ContributionResolveException { + if (policy instanceof EchoBindingEncryptionPolicy) { + EchoBindingEncryptionPolicy ePolicy = (EchoBindingEncryptionPolicy)policy; + + ClassReference classReference = new ClassReference(ePolicy.getEncryptionStrategyClassName()); + classReference = resolver.resolveModel(ClassReference.class, classReference); + Class javaClass = classReference != null ? classReference.getJavaClass() : null; + if (javaClass == null) { + //throw new ContributionResolveException(new ClassNotFoundException(ePolicy.getEncryptionStrategyClass())); + } + //ePolicy.setStrategyClass(javaClass); + //FIXME: need to resolve this thro resolver + try { + ePolicy.setStrategyClass((Class)Class.forName(ePolicy + .getEncryptionStrategyClassName())); + } catch (Exception e) { + throw new ContributionResolveException(e); + } + ePolicy.setStrategyClass(ePolicy.getStrategyClass()); + ePolicy.setUnresolved(false); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.java new file mode 100644 index 0000000000..deda8d9744 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionPolicyHandler.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 echo.provider.policy; + +import org.apache.tuscany.sca.policy.Policy; +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Sample policy handler + */ +public class EncryptionPolicyHandler implements PolicyHandler { + + public void applyPolicy(Object msg, PolicySet policySet) throws Exception { + for ( Object aPolicy : policySet.getPolicies() ) { + if ( aPolicy instanceof EchoBindingEncryptionPolicy ) { + encrypt(msg, (EchoBindingEncryptionPolicy)aPolicy); + } + } + } + + private void encrypt(Object msg, EchoBindingEncryptionPolicy policy) throws Exception { + if ( !policy.isUnresolved() && msg instanceof Object[] ) { + EncryptionStrategy strategy = policy.getStrategyClass().newInstance(); + Object[] msgArgs = (Object[])msg; + for ( int count = 0 ; count < msgArgs.length ; ++count ) { + msgArgs[count] = strategy.encryptMessage(msgArgs[count]); + } + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.java new file mode 100644 index 0000000000..ffadfc7fff --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/EncryptionStrategy.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 echo.provider.policy; + +/** + + */ +public interface EncryptionStrategy { + Object encryptMessage(Object msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java new file mode 100644 index 0000000000..6fa5f26977 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/PolicyHandler.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import org.apache.tuscany.sca.policy.PolicySet; + +/** + * Sample Policy Handler Interface + * + */ +public interface PolicyHandler { + void applyPolicy(Object msg, PolicySet policySet) throws Exception; +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.java new file mode 100644 index 0000000000..cf55b36fc2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/ReverseEncryptionStrategy.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 echo.provider.policy; + +/** + */ +public class ReverseEncryptionStrategy implements EncryptionStrategy { + + public Object encryptMessage(Object msg) { + if ( msg instanceof String ) { + StringBuffer sb = new StringBuffer((String)msg); + msg = sb.reverse().toString(); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java new file mode 100644 index 0000000000..ac610cfb51 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicy.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.policy.Policy; + +/** + + */ +public class WSPolicy implements Policy { + private boolean unresolved = true; + + public QName getSchemaName() { + return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java new file mode 100644 index 0000000000..0ac113df07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/provider/policy/WSPolicyProcessor.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo.provider.policy; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.policy.Policy; + +/** + * @author administrator + * + */ +public class WSPolicyProcessor implements StAXArtifactProcessor { + + public QName getArtifactType() { + return new QName("http://schemas.xmlsoap.org/ws/2004/09/policy", "PolicyAttachment"); + } + + public WSPolicy read(XMLStreamReader arg0) throws ContributionReadException, XMLStreamException { + return new WSPolicy(); + } + + public void write(WSPolicy arg0, XMLStreamWriter arg1) throws ContributionWriteException, + XMLStreamException { + + } + + public Class getModelType() { + // TODO Auto-generated method stub + return WSPolicy.class; + } + + public void resolve(WSPolicy arg0, ModelResolver arg1) throws ContributionResolveException { + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java new file mode 100644 index 0000000000..8ea2395d04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServer.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo.server; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +/** + * A sample Echo server, showing how to integrate service bindings. + */ +public class EchoServer { + + public static EchoServer server; + + private Map services = new HashMap(); + + public static void start() { + } + + public static void stop() { + } + + public static EchoServer getServer() { + if (server == null) + server = new EchoServer(); + return server; + } + + /** + * Register a service under the given name. + * + * @param service + * @param name + */ + public void register(String uri, EchoServiceListener service) { + if (services.isEmpty()) { + start(); + } + services.put(uri, service); + } + + public void unregister(String uri) { + services.remove(uri); + if (services.isEmpty()) { + stop(); + } + } + + /** + * Dispatch an incoming interaction to the corresponding service. + * + * @param uri + * @param input + * @return + */ + public String sendReceive(String uri, String input) throws InvocationTargetException { + return services.get(uri).sendReceive(input); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.java new file mode 100644 index 0000000000..32336dd94f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/java/echo/server/EchoServiceListener.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 echo.server; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; + +public class EchoServiceListener { + private Invoker invoker; + private MessageFactory messageFactory; + + public EchoServiceListener(Invoker invoker, MessageFactory messageFactory) { + super(); + this.invoker = invoker; + this.messageFactory = messageFactory; + } + + public String sendReceive(String input) throws InvocationTargetException { + + // Create a request message + Message request = messageFactory.createMessage(); + request.setBody(new Object[] {input}); + + // Dispatch and get the response + Message response = invoker.invoke(request); + Object body = response.getBody(); + if (response.isFault()) { + throw new InvocationTargetException((Throwable)body); + } + return (String)body; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory new file mode 100644 index 0000000000..55be293862 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/echo.EchoBindingFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding model factory +echo.impl.EchoBindingFactoryImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..06d53250c1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://echo#binding.echo,model=echo.EchoBinding,factory=echo.EchoBindingFactory +echo.provider.policy.EchoBindingEncryptionPolicyProcessor;qname=http://sample/policy#echoBindingPolicy,model=echo.provider.policy.EchoBindingEncryptionPolicy +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://schemas.xmlsoap.org/ws/2004/09/policy#PolicyAttachment,model=echo.provider.policy.WSPolicy diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..efa475ef92 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding provider extension +echo.provider.EchoBindingProviderFactory;model=echo.EchoBinding diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/Echo.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/Echo.java new file mode 100644 index 0000000000..1d5e973f33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/Echo.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +/** + * Interface of our sample Echo service. + * + * @version $Rev$ $Date$ + */ +public interface Echo { + + String echo(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java new file mode 100644 index 0000000000..ba68dfe908 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoComponentImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + + +/** + * A simple client component that uses a reference with an Echo binding. + * + * @version $Rev$ $Date$ + */ +public class EchoComponentImpl implements Echo { + + private Echo echoReference; + + @Constructor + public EchoComponentImpl(@Reference(name = "echoReference", required = true) Echo echoReference) { + this.echoReference = echoReference; + } + + public String echo(String msg) { + String result = echoReference.echo(msg); + System.out.println("Returned message: "+ result); + return result; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java new file mode 100644 index 0000000000..7383077f18 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoReferenceTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class EchoReferenceTestCase extends TestCase { + + private SCADomain scaDomain; + private Echo service; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoBinding.composite"); + service = scaDomain.getService(Echo.class, "EchoComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testEchoBinding() { + String result = service.echo("foo"); + assertEquals(result, "oof"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java new file mode 100644 index 0000000000..ab05516622 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/java/echo/EchoServiceTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import echo.server.EchoServer; + +/** + * @version $Rev$ $Date$ + */ +public class EchoServiceTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoBinding.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testEchoBinding() throws Exception { + String result = EchoServer.getServer().sendReceive("http://tempuri.org", "foo"); + assertEquals(result, "oof"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/EchoBinding.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/EchoBinding.composite new file mode 100644 index 0000000000..ecb6063010 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/EchoBinding.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/definitions.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/definitions.xml new file mode 100644 index 0000000000..a742804fb8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo-extension/src/test/resources/definitions.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ... + + + + ... + + + + + + + + + Protect messages from unauthorized reading or modification + + + + + + Protect messages from unauthorized reading or modification + + + + + + + Communitcation thro this binding must prevent + unauthorized users from reading the messages. + + + + + + Communitcation thro this binding must prevent + unauthorized modification of the messages. + + + + + + Communitcation thro this binding required + Authentication. + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/README b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/README new file mode 100644 index 0000000000..0aea36a081 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/README @@ -0,0 +1,99 @@ +Binding Echo Sample Application +=============================== +This sample demonstrates how to use the new binding extension +binding-echo-extension. + +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 ..\..\lib\tuscany-sca-manifest.jar;..\binding-echo-extension\target\sample-binding-echo-extension.jar;target\sample-binding-echo.jar echo.EchoBindingClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:../binding-echo-extension/target/sample-binding-echo-extension.jar:target/sample-binding-echo.jar echo.EchoBindingClient + +This looks like a long command. The three things we add to the classpath are + +tuscany-sca-manifest.jar - all of the standard Tuscany SCA runtime and + extension classes +sample-binding-echo-extension.jar - the new echo binding extension implementation +sample-binding-echo - the application that uses the echo binding + + +Sample Overview +--------------- +This sample contains an application (client and server code) that uses +an SCA binding that simply echoes back any messages that are sent to it. + +binding-echo/ + src/ + main/ + java/ + echo/ + Echo.java - interface definition for the sample + reference and service + EchoComponentImpl.java - sample component implementation with + echo binding reference + EchoBindingClient.java - sample client + resources/ + EchoBinding.composite - the SCA assembly for this sample + test/ + java/ + echo + EchoBindingTestCase.java - sample JUnit test case for the sample + client + binding-echo.png - 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 binding-echo +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Returned message: foo + [java] Echo reference = foo + [java] Returned message: bar + [java] Echo service = bar + + +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 binding-echo +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running echo.EchoBindingTestCase +Returned message: foo +Returned message: bar +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.811 sec + +Results : + +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.png b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.png new file mode 100644 index 0000000000..a38d985363 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.svg b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.svg new file mode 100644 index 0000000000..5b5051bef5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/binding-echo.svg @@ -0,0 +1,174 @@ + + + + + + + + + + image/svg+xml + + + + + + + + EchoBinding + + + EchoComponent + + + + EchoSerivce EchoReference + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/build.xml new file mode 100644 index 0000000000..7689ef3a54 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/pom.xml new file mode 100644 index 0000000000..ed85cf6c47 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/pom.xml @@ -0,0 +1,71 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-echo + Apache Tuscany Echo Binding Sample Application + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + sample-binding-echo-extension + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/Echo.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/Echo.java new file mode 100644 index 0000000000..1d5e973f33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/Echo.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +/** + * Interface of our sample Echo service. + * + * @version $Rev$ $Date$ + */ +public interface Echo { + + String echo(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoBindingClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoBindingClient.java new file mode 100644 index 0000000000..21bdff4011 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoBindingClient.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import echo.server.EchoServer; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + * @version $Rev$ $Date$ + */ +public class EchoBindingClient { + + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("EchoBinding.composite"); + + // Call the echo service component which will, in turn, call a reference + // with an echo binding. The echo binding will echo the given string. + Echo service = scaDomain.getService(Echo.class, "EchoComponent"); + String echoString = service.echo("foo"); + System.out.println("Echo reference = " + echoString ); + + // Call the echo server. This will dispatch the call to a service with an + // echo binding. The echo binding will pass the call to the echo component. + echoString = EchoServer.getServer().sendReceive("http://tempuri.org", "bar"); + System.out.println("Echo service = " + echoString ); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java new file mode 100644 index 0000000000..ba68dfe908 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/java/echo/EchoComponentImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + + +/** + * A simple client component that uses a reference with an Echo binding. + * + * @version $Rev$ $Date$ + */ +public class EchoComponentImpl implements Echo { + + private Echo echoReference; + + @Constructor + public EchoComponentImpl(@Reference(name = "echoReference", required = true) Echo echoReference) { + this.echoReference = echoReference; + } + + public String echo(String msg) { + String result = echoReference.echo(msg); + System.out.println("Returned message: "+ result); + return result; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/resources/EchoBinding.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/resources/EchoBinding.composite new file mode 100644 index 0000000000..94612fb325 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/main/resources/EchoBinding.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java new file mode 100644 index 0000000000..1a597fc80f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-echo/src/test/java/echo/EchoBindingTestCase.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import echo.Echo; +import echo.server.EchoServer; + +public class EchoBindingTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoBinding.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testReference() throws Exception { + // Call the echo service component which will, in turn, call a reference + // with an echo binding. The echo binding will echo the given string. + Echo service = scaDomain.getService(Echo.class, "EchoComponent"); + String echoString = service.echo("foo"); + assertEquals(echoString, "foo"); + } + + public void testService() throws Exception { + // Call the echo server. This will dispatch the call to a service with an + // echo binding. The echo binding will pass the call to the echo component. + String echoString = EchoServer.getServer().sendReceive("http://tempuri.org", "bar"); + assertEquals(echoString, "bar"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/README b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/README new file mode 100644 index 0000000000..eb3322cf9b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/README @@ -0,0 +1,95 @@ +Notification Broker Binding Sample +================================== + +This sample illustrates the use of with a +broker. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +Sample Overview +--------------- + +This sample illustrates the use of a notification broker that is located in a +separate (and remote) composite with respect to any producers or consumers. As +such, this sample is run in conjunction with the binding-notification-producer +sample, the binding-notification-consumer sample, or both. Take a look at the +composite file or the .svg file which shows the composite file in pictorial form. +The composite service and composite reference each have a +that handles the remote communication. This binding includes an 'ntm' attribute +that refers to the notification type manager, which manages the connectivity of +producers, consumers and brokers, and which (for this sample) is assumed to be +running on http://localhost:8083. The ntm is a system component that is included in +and runs as part of the binding-notification module. +This sample also illustrates the use of a wsdl interface in the notification +component's . This allows messages sent and received +via to be transported as literal xml over http. + +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 binding-notification-broker +mvn + +Sample Usage +------------ + +This sample is run using the tuscany binary distribution. To run it, first set the +following environment variables: + +set MAVEN_REPO= +set NOTIFICATION_IMPL_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-implementation-notification\1.0-incubating-SNAPSHOT\tuscany-implementation-notification-1.0-incubating-SNAPSHOT.jar +set NOTIFICATION_BINDING_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-binding-notification\1.0-incubating-SNAPSHOT\tuscany-binding-notification-1.0-incubating-SNAPSHOT.jar +set STAX_JAR=%MAVEN_REPO%\stax\stax\1.1.1-dev\stax-1.1.1-dev.jar +set TUSCANY_BIN_DISTRO= +set TUSCANY_SCA_MANIFEST_JAR=%TUSCANY_BIN_DISTRO%\lib\tuscany-sca-manifest.jar + +Then navigate to this sample directory and do: + +java -Dnotification.httpPort=8080 -cp "target\sample-binding-notification-broker-1.0-incubating-SNAPSHOT.jar;%NOTIFICATION_IMPL_JAR%;%NOTIFICATION_BINDING_JAR%;%STAX_JAR%;%TUSCANY_SCA_MANIFEST_JAR%" notification.broker.TrafficAdvisoryServer + +this should bring up the following prompt: + +Send a report value, ^C or to end + +at this point you should be able to type a message to send, for instance: + +Traffic congestion + +Notice that before you try to receive any message, you should bring up the +consumer sample or another broker sample. When you have finished using this +sample, type 'end' or ^C to end. + +Also notice that '-Dnotification.httpPort=8080' is used in the java command. +This indicates the port the sample should use. This also says that this server +is not going to play the role of ntm, given our previous assumption. It is important +that the first one of the producer, consumer or broker sample that is run be the +one that uses '-Dnotification.httpPort=8083', otherwise there is no ntm to talk +to and an exception will be thrown. + +Sample directory structure: +--------------------------- + +binding-notification-broker/ + src/ + main/ + java/ + notification.broker/ + TestCaseProducer.java - interface for the producer component + TrafficAdvisory.java - remote interface referred to by the producer component + and for the consumer component + TrafficAdvisoryConsumer.java - implementation for the consumer components + TrafficAdvisoryProducer.java - implementation for the producer component + TrafficAdvisoryServer.java - server class including main entry point + resources/ + wsdl/ + TrafficAdvisory.wsdl - remote interface for the notification component + TrafficAdvisoryNotification.componentType - the component type referred to by + + TrafficAdvisoryNotification.composite - the main composite including producer, consumer and + notification components, and composite service and reference + pom.xml - the Maven build file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/binding-notification-broker.png b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/binding-notification-broker.png new file mode 100644 index 0000000000..49030650f2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/binding-notification-broker.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/pom.xml new file mode 100644 index 0000000000..d002219743 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-notification-broker + Apache Tuscany Notification Binding Broker Sample + 0.99-incubating-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-binding-notification + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-databinding + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java new file mode 100644 index 0000000000..35fa1a9ee9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TestCaseProducer.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification.broker; + +public interface TestCaseProducer { + + public void produceTrafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.java new file mode 100644 index 0000000000..d5bc8fbb50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisory.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 notification.broker; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface TrafficAdvisory { + + void trafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..a89fa8a913 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryConsumer.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 notification.broker; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ +@Service(TrafficAdvisory.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryConsumer implements TrafficAdvisory { + + @Property + protected String name; + + public void trafficNotification(String report) { + + System.out.println("Consumer [" + name + "] received report: " + report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.java new file mode 100644 index 0000000000..8caefaf1d2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryProducer.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 notification.broker; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(TestCaseProducer.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryProducer implements TestCaseProducer { + + @Reference + protected TrafficAdvisory destination; + + public void produceTrafficNotification(String report) { + + destination.trafficNotification(report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..430e9d6db7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/java/notification/broker/TrafficAdvisoryServer.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 notification.broker; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.URI; + +import org.apache.tuscany.sca.binding.notification.NotificationBindingProviderFactory; +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class TrafficAdvisoryServer { + + private static URI notificationType; + + public static void main(String[] args) { + try { + notificationType = new URI("trafficAdvisory"); + String compositeName = "TrafficAdvisoryNotification.composite"; + SCADomain domain = SCADomain.newInstance(compositeName); + TestCaseProducer testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + String value = null; + do { + try { + System.out.println("Send a report value, ^C or to end"); + value = reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + if(value == null || value.equals("end")) { + break; + } + if (value.equals("rb")) { + NotificationBindingProviderFactory.removeBroker(notificationType); + } + else { + testCaseProducer.produceTrafficNotification("Report value [" + value + "]"); + } + } + while(true); + + domain.close(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..031f6aafd0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..1a369d880d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-broker/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/README b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/README new file mode 100644 index 0000000000..00340765e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/README @@ -0,0 +1,89 @@ +Notification Consumer Binding Sample +=============================== + +This sample illustrates the use of with a +remote consumer. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +Sample Overview +--------------- + +This sample illustrates the use of a notification consumer that is located in a +separate (and remote) composite with respect to any producers. As such, this sample +is run in conjunction with the binding-notification-producer sample, the +binding-notification-broker sample, or both. Take a look at the composite file +or the .svg file which shows the composite file in pictorial form. The composite +service, wired to the notification component, has a +that handles the remote communication. This binding includes an 'ntm' attribute +that refers to the notification type manager, which manages the connectivity of +producers, consumers and brokers, and which (for this sample) is assumed to be +running on http://localhost:8083. The ntm is a system component that is included in +and runs as part of the binding-notification module. +This sample also illustrates the use of a wsdl interface in the notification +component's . This allows messages sent and received +via to be transported as literal xml over http. + +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 binding-notification-consumer +mvn + +Sample Usage +------------ + +This sample is run using the tuscany binary distribution. To run it, first set the +following environment variables: + +set MAVEN_REPO= +set NOTIFICATION_IMPL_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-implementation-notification\1.0-incubating-SNAPSHOT\tuscany-implementation-notification-1.0-incubating-SNAPSHOT.jar +set NOTIFICATION_BINDING_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-binding-notification\1.0-incubating-SNAPSHOT\tuscany-binding-notification-1.0-incubating-SNAPSHOT.jar +set STAX_JAR=%MAVEN_REPO%\stax\stax\1.1.1-dev\stax-1.1.1-dev.jar +set TUSCANY_BIN_DISTRO= +set TUSCANY_SCA_MANIFEST_JAR=%TUSCANY_BIN_DISTRO%\lib\tuscany-sca-manifest.jar + +Then navigate to this sample directory and do: + +java -Dnotification.httpPort=8082 -cp "target\sample-binding-notification-consumer-1.0-incubating-SNAPSHOT.jar;%NOTIFICATION_IMPL_JAR%;%NOTIFICATION_BINDING_JAR%;%STAX_JAR%;%TUSCANY_SCA_MANIFEST_JAR%" notification.consumer.TrafficAdvisoryServer + +this should bring up the following prompt: + +TrafficAdvisoryServer, hit return to end + +at this point you should be able to receive messages. + +Notice that before you try to receive any message, you should bring up the +producer sample or the broker sample. When you have finished using this +sample, hit return to end. + +Also notice that '-Dnotification.httpPort=8082' is used in the java command. +This indicates the port the sample should use. This also says that this server +is not going to play the role of ntm, given our previous assumption. It is important +that the first one of the producer, consumer or broker sample that is run be the +one that uses '-Dnotification.httpPort=8083', otherwise there is no ntm to talk +to and an exception will be thrown. + +Sample directory structure: +--------------------------- + +binding-notification-consumer/ + src/ + main/ + java/ + notification.consumer/ + TrafficAdvisory.java - remote interface referred to by the producer component + TrafficAdvisoryConsumer.java - implementation for the consumer components + TrafficAdvisoryServer.java - server class including main entry point + resources/ + wsdl/ + TrafficAdvisory.wsdl - remote interface for the notification component + TrafficAdvisoryNotification.componentType - the component type referred to by + + TrafficAdvisoryNotification.composite - the main composite including producer and + notification components, and composite reference + pom.xml - the Maven build file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/binding-notification-consumer.png b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/binding-notification-consumer.png new file mode 100644 index 0000000000..33e1966c3e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/binding-notification-consumer.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/pom.xml new file mode 100644 index 0000000000..677c96e5e1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/pom.xml @@ -0,0 +1,96 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-notification-consumer + Apache Tuscany Notification Binding Consumer Sample + 0.99-incubating-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.java new file mode 100644 index 0000000000..0efd1195bc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisory.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 notification.consumer; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface TrafficAdvisory { + + void trafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..6b88389d0c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryConsumer.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 notification.consumer; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ +@Service(TrafficAdvisory.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryConsumer implements TrafficAdvisory { + + @Property + protected String name; + + public void trafficNotification(String report) { + + System.out.println("Consumer [" + name + "] received report: " + report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..0f4e037df9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/java/notification/consumer/TrafficAdvisoryServer.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification.consumer; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class TrafficAdvisoryServer { + + public static void main(String[] args) { + try { + SCADomain domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + + try { + System.out.println("TrafficAdvisoryServer, hit return to end"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + domain.close(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..031f6aafd0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..e6ef9ee09a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-consumer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/README b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/README new file mode 100644 index 0000000000..6fb124bf9b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/README @@ -0,0 +1,118 @@ +Notification Producer Binding Sample +=============================== + +This sample illustrates the use of with a +remote producer. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +Sample Overview +--------------- + +This sample illustrates the use of a notification producer that is located in a +separate (and remote) composite with respect to any consumers. As such, this sample +is run in conjunction with the binding-notification-consumer sample, the +binding-notification-broker sample, or both. Take a look at the composite file +or the .svg file which shows the composite file in pictorial form. The composite +reference, referred to by the notification component, has a +that handles the remote communication. This binding includes an 'ntm' attribute +that refers to the notification type manager, which manages the connectivity of +producers, consumers and brokers, and which (for this sample) is assumed to be +running on http://localhost:8083. The ntm is a system component that is included in +and runs as part of the binding-notification module. +This sample also illustrates the use of a wsdl interface in the notification +component's . This allows messages sent and received +via to be transported as literal xml over http. + +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 binding-notification-producer +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running notification.producer.TrafficAdvisoryTestCase +Only instantiating and closing domain ... +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.252 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. + +Sample Usage +------------ + +This sample is run using the tuscany binary distribution. To run it, first set the +following environment variables: + +set MAVEN_REPO= +set NOTIFICATION_IMPL_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-implementation-notification\1.0-incubating-SNAPSHOT\tuscany-implementation-notification-1.0-incubating-SNAPSHOT.jar +set NOTIFICATION_BINDING_JAR=%MAVEN_REPO%\org\apache\tuscany\sca\tuscany-binding-notification\1.0-incubating-SNAPSHOT\tuscany-binding-notification-1.0-incubating-SNAPSHOT.jar +set STAX_JAR=%MAVEN_REPO%\stax\stax\1.1.1-dev\stax-1.1.1-dev.jar +set TUSCANY_BIN_DISTRO= +set TUSCANY_SCA_MANIFEST_JAR=%TUSCANY_BIN_DISTRO%\lib\tuscany-sca-manifest.jar + +Then navigate to this sample directory and do: + +java -Dnotification.httpPort=8083 -cp "target\sample-binding-notification-producer-1.0-incubating-SNAPSHOT.jar;%NOTIFICATION_IMPL_JAR%;%NOTIFICATION_BINDING_JAR%;%STAX_JAR%;%TUSCANY_SCA_MANIFEST_JAR%" notification.producer.TrafficAdvisoryServer + +this should bring up the following prompt: + +Send a report value, ^C or to end + +at this point you should be able to type a message to send, for instance: + +Traffic congestion + +Notice that before you try to send any message, you should bring up the +consumer sample or the broker sample. When you have finished using this +sample, type 'end' or ^C to end. + +Also notice that '-Dnotification.httpPort=8083' is used in the java command. +This indicates the port the sample should use. This also says that this server +is going to play the role of ntm, given our previous assumption. It is important +that the first one of the producer, consumer or broker sample that is run be the +one that uses '-Dnotification.httpPort=8083', otherwise there is no ntm to talk +to and an exception will be thrown. + +Sample directory structure: +--------------------------- + +binding-notification-producer/ + src/ + main/ + java/ + notification.producer/ + TestCaseProducer.java - interface for the producer component + TrafficAdvisory.java - remote interface referred to by the producer component + TrafficAdvisoryProducer.java - implementation for the producer component + TrafficAdvisoryServer.java - server class including main entry point + resources/ + wsdl/ + TrafficAdvisory.wsdl - remote interface for the notification component + TrafficAdvisoryNotification.componentType - the component type referred to by + + TrafficAdvisoryNotification.composite - the main composite including producer and + notification components, and composite reference + test/ + java/ + notification.producer/ + TrafficAdvisoryTestCase.java - JUnit test case + resources/ + wsdl/ + TrafficAdvisory.wsdl - remote interface for the notification component + TrafficAdvisoryNotification.componentType - the component type referred to by + + TrafficAdvisoryNotification.composite - the main composite including producer and + notification components, and composite reference + pom.xml - the Maven build file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/binding-notification-producer.png b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/binding-notification-producer.png new file mode 100644 index 0000000000..34c347c893 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/binding-notification-producer.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/pom.xml new file mode 100644 index 0000000000..b172f56305 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/pom.xml @@ -0,0 +1,100 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-notification-producer + Apache Tuscany Notification Binding Producer Sample + 0.99-incubating-SNAPSHOT + A sample illustrating use of binding.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-notification + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.apache.tuscany.notification.remoteProducer.TrafficAdvisoryServer + + + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java new file mode 100644 index 0000000000..be80e71249 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TestCaseProducer.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification.producer; + +public interface TestCaseProducer { + + public void produceTrafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.java new file mode 100644 index 0000000000..39f06d5dde --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisory.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 notification.producer; + +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@Remotable +public interface TrafficAdvisory { + + void trafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.java new file mode 100644 index 0000000000..7d49b00607 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryProducer.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 notification.producer; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(TestCaseProducer.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryProducer implements TestCaseProducer { + + @Reference + protected TrafficAdvisory destination; + + public void produceTrafficNotification(String report) { + + destination.trafficNotification(report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.java new file mode 100644 index 0000000000..235b180be8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/java/notification/producer/TrafficAdvisoryServer.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 notification.producer; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class TrafficAdvisoryServer { + + public static void main(String[] args) { + try { + SCADomain domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + TestCaseProducer testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); + String value = null; + do { + try { + System.out.println("Send a report value, ^C or to end"); + value = reader.readLine(); + } catch (IOException e) { + e.printStackTrace(); + } + if(value == null || value.equals("end")) { + break; + } + testCaseProducer.produceTrafficNotification("Report value [" + value + "]"); + } + while(true); + + domain.close(); + } catch(Throwable e) { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..031f6aafd0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..3f8436cb24 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/main/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.java new file mode 100644 index 0000000000..e01175cfeb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/java/notification/producer/TrafficAdvisoryTestCase.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 notification.producer; + +import notification.producer.TestCaseProducer; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +//import org.apache.tuscany.sca.notification.remoteProducer.TestCaseProducer; + +import junit.framework.TestCase; + +public class TrafficAdvisoryTestCase extends TestCase { + + private SCADomain domain; + + public void testTrafficAdvisoryNotification() throws Exception { + System.out.println("Only instantiating and closing domain ..."); + } + + @Override + protected void setUp() throws Exception { + try { + domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + } catch(Throwable e) { + e.printStackTrace(); + if (e instanceof Exception) { + throw (Exception)e; + } + else { + throw new Exception(e); + } + } + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..031f6aafd0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..f4b4f2d5f2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/wsdl/TrafficAdvisory.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/wsdl/TrafficAdvisory.wsdl new file mode 100644 index 0000000000..b823bbebcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/binding-notification-producer/src/test/resources/wsdl/TrafficAdvisory.wsdl @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/README new file mode 100644 index 0000000000..81dd0c64e6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/README @@ -0,0 +1,297 @@ +Calculator Distributed Sample +============================= +This sample implements a simple calculator using SCA components. It uses +exactly the same calculator application classes as the calculator sample but +runs the application distributed across three nodes. + +A node in this sample means an instance of the Tuscany SCA java runtime running +in a Java virtual machine. + +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 four command prompts and +navigate to this sample directory in each one. There is one command to be run +in each command prompt: + +ant runDomainNode +ant runNodeB +ant runNodeC +ant runNodeA + +Please run the commands in this order. + +OR if you don't have ant, on Windows use + +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.DomainNode +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.CalculatorNode mydomain nodeB +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.CalculatorNode mydomain nodeC +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.CalculatorNode mydomain nodeA + +and on *nix do + +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.DomainNode +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.CalculatorNode mydomain nodeB +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.CalculatorNode mydomain nodeC +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.CalculatorNode mydomain nodeA + + +The processes started on each of these command prompts can be ended by pressing +the key. + + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. NodeA exercises this interface by calling add, subtract, multiply and +divide operations. + +In the case of add and subtract the runtime recognises that +it can't find these services locally and, using the remote (web services) +version of the default SCA binding contacts the add service running in NodeB +and the subtract service running in NodeC. + +On the command prompt where you started NodeA, you would see output of invoking the +calculator functions distributed over NodeB and and NodeC. On the command prompts +where you have started NodeB and NodeC, you would see log messages that indicate that +the add and substract services where called on these nodes respectively. + +The sample demonstrates that the calculator application can be distributed +across multiple nodes with no change to the application or to the SCA description +files. + + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + 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 + node/ + CalculatorNode.java - runs up an sca application based on + configuration given on the command + line in the form + + CalculatorNode + + it looks for a directory name the same + as and loads the composites + there + + if = nodeA it calls the + +-/* operations otherwise it behaves + like a server and waits for service + requests + DomainNode.java - the node that provides the service + discovery mechanism to the distributed + domain + resources/ + domain - the SCA assembly for the service discovery + function + management/ - the SCA assembly for each nodes management + function + nodeA - the SCA assembly for nodeA's part of the + calculator application + nodeB - the SCA assembly for nodeB's part of the + calculator application + nodeC - the SCA assembly for nodeB's part of the + calculator application + test/ + java/ + calculator/ + DomainInMemoryTestCase.java - JUnit test case which runs all of the + separate ndes in a single VM for test + purposes + calculator-distributed.png - a pictorial representation of the sample + .composite files + 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-distributed +ant compile +ant runDomainNode +ant runNodeB +ant runNodeC +ant runNodeA + +You should see the following output from the four separate command prompt: + +runDomainNode: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] 23-Aug-2007 17:40:40 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8080/ServiceDiscoveryC +omponent/ServiceDiscovery + [java] Domain node started (press enter to shutdown) + [java] Registering service: [mydomain nodeB AddServiceComponent org.apache. +tuscany.sca.assembly.SCABinding http://localhost:8085/AddServiceComponent] + [java] Registering service: [mydomain nodeC SubtractServiceComponent org.ap +ache.tuscany.sca.assembly.SCABinding http://localhost:8086/SubtractServiceCompon +ent] + [java] Finding service: [mydomain SubtractServiceComponent org.apache.tusca +ny.sca.assembly.SCABinding] + [java] Matching service url: http://localhost:8086/SubtractServiceComponent + + [java] Finding service: [mydomain AddServiceComponent org.apache.tuscany.sc +a.assembly.SCABinding] + [java] Matching service url: http://localhost:8085/AddServiceComponent + [java] Java Result: 1 +Terminate batch job (Y/N)? y + + + +runNodeB: + [java] file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/ +target/classes/management/ + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Registering service: [mydomain nodeB AddServiceComponent/ org.apache +.tuscany.sca.assembly.SCABinding http://localhost:8085/AddServiceComponent] + [java] 23-Aug-2007 17:41:25 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/AddServiceCompone +nt + [java] Node started (press enter to shutdown) + [java] AddService - add 3.0 and 2.0 + + +runNodeC: + [java] file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/ +target/classes/management/ + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Registering service: [mydomain nodeC SubtractServiceComponent org.ap +ache.tuscany.sca.assembly.SCABinding http://localhost:8086/SubtractServiceCompon +ent] + [java] 23-Aug-2007 17:41:51 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] Node started (press enter to shutdown) + [java] INFO: Added Servlet mapping: http://localhost:8086/SubtractServiceCo +mponent + [java] SubtractService - subtract 3.0 and 2.0 +Terminate batch job (Y/N)? y + + +runNodeA: + [java] file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/ +target/classes/management/ + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] 23-Aug-2007 17:42:12 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: [WARNING] Component reference target not found, it might be + a remote service: AddServiceComponent null + [java] + [java] 23-Aug-2007 17:42:12 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: [WARNING] Component reference target not found, it might be + a remote service: SubtractServiceComponent null + [java] + [java] Finding service: [mydomain SubtractServiceComponent org.apache.tusca +ny.sca.assembly.SCABinding] + [java] Finding service: [mydomain AddServiceComponent org.apache.tuscany.sc +a.assembly.SCABinding] + [java] CalculatorService - add 3.0 and 2.0 + [java] 3 + 2=5.0 + [java] CalculatorService - subtract 3.0 and 2.0 + [java] 3 - 2=1.0 + [java] CalculatorService - multiply 3.0 and 2.0 + [java] 3 * 2=6.0 + [java] CalculatorService - divide 3.0 and 2.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. When running from Maven the four nodes all run within +Java virtual machine. + +cd calculator-distributed +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running calculator.DomainInMemoryTestCase +Setting up distributed nodes +file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/target/class +es/management/ +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +23-Aug-2007 18:18:41 org.apache.tuscany.sca.assembly.builder.impl.CompositeBuild +erImpl$1 problem +WARNING: [WARNING] Component reference target not found, it might be a remote se +rvice: AddServiceComponent null + +23-Aug-2007 18:18:41 org.apache.tuscany.sca.assembly.builder.impl.CompositeBuild +erImpl$1 problem +WARNING: [WARNING] Component reference target not found, it might be a remote se +rvice: SubtractServiceComponent null + +file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/target/class +es/management/ +Registering service: [mydomain nodeB AddServiceComponent org.apache.tuscany.sca. +assembly.SCABinding http://localhost:8085/AddServiceComponent] +file:/C:/simon/tuscany/java-head/sca/samples/calculator-distributed/target/class +es/management/ +Registering service: [mydomain nodeC SubtractServiceComponent org.apache.tuscany +.sca.assembly.SCABinding http://localhost:8086/SubtractServiceComponent] +Finding service: [mydomain SubtractServiceComponent org.apache.tuscany.sca.assem +bly.SCABinding] +Matching service url: http://localhost:8086/SubtractServiceComponent +Finding service: [mydomain AddServiceComponent org.apache.tuscany.sca.assembly.S +CABinding] +Matching service url: http://localhost:8085/AddServiceComponent +23-Aug-2007 18:18:45 org.apache.tuscany.sca.http.jetty.JettyServer addServletMap +ping +INFO: Added Servlet mapping: http://localhost:8085/AddServiceComponent +23-Aug-2007 18:18:47 org.apache.tuscany.sca.http.jetty.JettyServer addServletMap +ping +INFO: Added Servlet mapping: http://localhost:8086/SubtractServiceComponent +CalculatorService - add 3.0 and 2.0 +AddService - add 3.0 and 2.0 +CalculatorService - subtract 3.0 and 2.0 +SubtractService - subtract 3.0 and 2.0 +CalculatorService - multiply 3.0 and 2.0 +CalculatorService - divide 3.0 and 2.0 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 7.14 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + + +This shows that the Junit test cases have run successfully. + +Known Bug : +--------- +The processes that are running NodeB and NodeC do not seem to end on pressing the +. This will be fixed for the next release. For this release you should use +^C (Control C) to exit these processes. + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/build.xml new file mode 100644 index 0000000000..96c79607ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/build.xml @@ -0,0 +1,229 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.png new file mode 100644 index 0000000000..7c0e175664 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.svg new file mode 100644 index 0000000000..be5a4b8185 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/calculator-distributed.svg @@ -0,0 +1,383 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + + nodeB nodeC + nodeA + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/pom.xml new file mode 100644 index 0000000000..51f0f3cbe8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/pom.xml @@ -0,0 +1,101 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 0.99-incubating-SNAPSHOT + ../pom.xml + + sample-calculator-distributed + Apache Tuscany Distributed Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + + org.apache.tuscany.sca + tuscany-distributed + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-distributed-impl + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-topology + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-topology-xml + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 0.99-incubating-SNAPSHOT + + + + + + org.apache.tuscany.sca + tuscany-http-jetty + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..d7dc4473ad --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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.osoa.sca.annotations.Remotable; + +/** + * The Add service interface + */ +@Remotable +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9b7e254e5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.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; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + System.out.println("AddService - add " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..da869e00fd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.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 setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + public double add(double n1, double n2) { + System.out.println("CalculatorService - add " + n1 + " and " + n2); + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + System.out.println("CalculatorService - subtract " + n1 + " and " + n2); + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + System.out.println("CalculatorService - multiply " + n1 + " and " + n2); + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + System.out.println("CalculatorService - divide " + n1 + " and " + n2); + return divideService.divide(n1, n2); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..78ab9c6ee0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the multiply service + */ +@Remotable +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1010207154 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.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; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + System.out.println("SubtractService - subtract " + n1 + " and " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/CalculatorNode.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/CalculatorNode.java new file mode 100644 index 0000000000..bb939816bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/CalculatorNode.java @@ -0,0 +1,114 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package node; + +import java.io.File; +import java.io.IOException; +import java.net.URL; + +import org.apache.tuscany.sca.assembly.Binding; +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +import org.apache.tuscany.sca.assembly.ComponentService; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.assembly.SCABinding; +import org.apache.tuscany.sca.binding.sca.impl.SCABindingImpl; +import org.apache.tuscany.sca.contribution.Contribution; +import org.apache.tuscany.sca.contribution.service.ContributionService; +import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain; +import org.apache.tuscany.sca.distributed.domain.impl.DistributedSCADomainMemoryImpl; +import org.apache.tuscany.sca.distributed.domain.impl.DistributedSCADomainNetworkImpl; +import org.apache.tuscany.sca.distributed.node.impl.EmbeddedNode; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain; + +import calculator.CalculatorService; + +/** + * This client program shows how to run a distributed SCA node. In this case a + * calculator node has been constructed specifically for running the calculator + * composite. Internally it creates a representation of a node and associates a + * distributed domain with the node. This separation is made different implementations + * of the distributed domain can be provided. + */ +public class CalculatorNode { + + + public static void main(String[] args) throws Exception { + + // Check that the correct arguments have been provided + if (null == args || args.length != 2) { + System.err.println("Useage: java CalculatorNode domainname nodename"); + System.exit(1); + } + + try { + String domainName = args[0]; + String nodeName = args[1]; + + // Create the distributed domain representation. We use the network implementation + // here so that the node contacts a registry running somewhere out on the + // network. + DistributedSCADomain distributedDomain = new DistributedSCADomainNetworkImpl(domainName); + + // create the node that runs the calculator component + EmbeddedNode node = new EmbeddedNode(nodeName); + SCADomain domain = node.attachDomain(distributedDomain); + + // the application components are added. The null here just gets the node + // implementation to read a directory from the classpath with the node name + // TODO - should be done as a management action. + node.addContribution(domainName, null); + + // start the node + // TODO - should be done as a management action. + node.start(); + + // nodeA is the head node and runs some tests while all other nodes + // simply listen for incoming messages + if ( nodeName.equals("nodeA") ) { + // do some application stuff + CalculatorService calculatorService = + domain.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)); + } else { + // start up and wait for messages + try { + System.out.println("Node started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // stop the node and all the domains in it + domain.close(); + + } catch(Exception ex) { + System.err.println("Exception in node - " + ex.getMessage()); + ex.printStackTrace(System.err); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/DomainNode.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/DomainNode.java new file mode 100644 index 0000000000..9abfc03606 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/java/node/DomainNode.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 node; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This server program that loads a composite to provide simple registry function. + * This server can be replaced with any registry that is appropriate but the components + * in each node that talk to the registry should be replaced also. + */ +public class DomainNode { + + public static void main(String[] args) { + + SCADomain scaDomain = SCADomain.newInstance("domain/domain.composite"); + + try { + System.out.println("Domain node started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("Domain node stopped"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3f9ed8024b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/domain.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/domain.composite new file mode 100644 index 0000000000..a11d94aa93 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/domain/domain.composite @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..b73217ebb8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/management.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/management.composite new file mode 100644 index 0000000000..68f466344a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/management/management.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite new file mode 100644 index 0000000000..a111dfd064 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3f9ed8024b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite new file mode 100644 index 0000000000..bf226d9109 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3f9ed8024b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite new file mode 100644 index 0000000000..4ef4c5ddb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..3f9ed8024b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java new file mode 100644 index 0000000000..a6d47115a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-distributed/src/test/java/calculator/DomainInMemoryTestCase.java @@ -0,0 +1,115 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + + +import java.io.File; +import java.net.URL; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.distributed.domain.DistributedSCADomain; +import org.apache.tuscany.sca.distributed.domain.impl.DistributedSCADomainMemoryImpl; +import org.apache.tuscany.sca.distributed.node.impl.EmbeddedNode; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import calculator.CalculatorService; + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class DomainInMemoryTestCase { + + private static String DEFULT_DOMAIN_NAME = "mydomain"; + + private static DistributedSCADomain distributedDomain; + private static EmbeddedNode nodeA; + private static SCADomain domainA; + private static EmbeddedNode nodeB; + private static SCADomain domainB; + private static EmbeddedNode nodeC; + private static SCADomain domainC; + private static CalculatorService calculatorServiceA; + + @BeforeClass + public static void init() throws Exception { + System.out.println("Setting up distributed nodes"); + + File currentDirectory = new File ("."); + URL contributionURL = null; + + // Create the distributed domain representation + distributedDomain = new DistributedSCADomainMemoryImpl(DEFULT_DOMAIN_NAME); + + // create the node that runs the + // calculator component + nodeA = new EmbeddedNode("nodeA"); + domainA = nodeA.attachDomain(distributedDomain); + contributionURL = Thread.currentThread().getContextClassLoader().getResource("nodeA/"); + nodeA.addContribution(DEFULT_DOMAIN_NAME, contributionURL); + + // create the node that runs the + // add component + nodeB = new EmbeddedNode("nodeB"); + domainB = nodeB.attachDomain(distributedDomain); + contributionURL = Thread.currentThread().getContextClassLoader().getResource("nodeB/"); + nodeB.addContribution(DEFULT_DOMAIN_NAME, contributionURL); + + // create the node that runs the + // subtract component + nodeC = new EmbeddedNode("nodeC"); + domainC = nodeC.attachDomain(distributedDomain); + contributionURL = Thread.currentThread().getContextClassLoader().getResource("nodeC/"); + nodeC.addContribution(DEFULT_DOMAIN_NAME, contributionURL); + + + // start all of the nodes + nodeA.start(); + nodeB.start(); + nodeC.start(); + + // get a reference to the calculator service from domainA + // which will be running this component + calculatorServiceA = domainA.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @AfterClass + public static void destroy() throws Exception { + // stop the nodes and hence the domains they contain + nodeA.stop(); + nodeB.stop(); + nodeC.stop(); + } + + @Test + public void testCalculator() throws Exception { + + // Calculate + Assert.assertEquals(calculatorServiceA.add(3, 2), 5.0); + Assert.assertEquals(calculatorServiceA.subtract(3, 2), 1.0); + Assert.assertEquals(calculatorServiceA.multiply(3, 2), 6.0); + Assert.assertEquals(calculatorServiceA.divide(3, 2), 1.5); + + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/README new file mode 100644 index 0000000000..837b5ce75f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer + +and on *nix do + +java -cp ../../lib/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 ..\..\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 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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/build.xml new file mode 100644 index 0000000000..30817fe6f0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.png new file mode 100644 index 0000000000..8c76b77a9f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/calculator-rmi-reference.svg new file mode 100644 index 0000000000..ba802e6717 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/pom.xml new file mode 100644 index 0000000000..80b5252cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator-rmi-reference + Apache Tuscany Calculator Sample using an RMI Service Reference + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi + 0.99-incubating-SNAPSHOT + runtime + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..cd1076c3f1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * 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 { + SCADomain scaDomain = SCADomain.newInstance("CalculatorRMIReference.composite"); + CalculatorService calculatorService = + scaDomain.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)); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..d310dad4b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite new file mode 100644 index 0000000000..a5a6e1cd29 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/main/resources/CalculatorRMIReference.composite @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java new file mode 100644 index 0000000000..15e00f5946 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIReferenceTestCase.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorRMIReferenceTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + CalculatorRMIServiceImpl rmiCalculatorImpl = new CalculatorRMIServiceImpl(); + Registry rmiRegistry = LocateRegistry.createRegistry(8099); + rmiRegistry.bind("CalculatorRMIService", rmiCalculatorImpl); + + scaDomain = SCADomain.newInstance("CalculatorRMIReference.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + LocateRegistry.getRegistry(8099).unbind("CalculatorRMIService"); + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-reference/src/test/java/calculator/CalculatorRMIServiceImpl.java new file mode 100644 index 0000000000..d8ded42cb2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/README new file mode 100644 index 0000000000..454cdc0d37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-rmi-service.jar calculator.CalculatorServer + +and on *nix do + +java -cp ../../lib/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/build.xml new file mode 100644 index 0000000000..f98f35e4b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.png new file mode 100644 index 0000000000..574f5eb14b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/calculator-rmi-service.svg new file mode 100644 index 0000000000..9253110f98 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/pom.xml new file mode 100644 index 0000000000..fc1ca5f734 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/pom.xml @@ -0,0 +1,68 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator-rmi-service + Apache Tuscany Calculator Sample exposing as RMI Service + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-binding-rmi + 0.99-incubating-SNAPSHOT + runtime + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..2b99485b68 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.java new file mode 100644 index 0000000000..b698163c1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServer.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 org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * 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..."); + SCADomain scaDomain = SCADomain.newInstance("CalculatorRMIServer.composite"); + System.out.println("... Press Enter to Exit..."); + System.in.read(); + scaDomain.close(); + System.out.println("Exited..."); + System.exit(0); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..3ddcef61df --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..f28f0ca179 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite new file mode 100644 index 0000000000..86322c248c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/main/resources/CalculatorRMIServer.composite @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java new file mode 100644 index 0000000000..8943dd24f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-rmi-service/src/test/java/calculator/CalculatorRMIServerTestCase.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import java.rmi.Naming; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorRMIServerTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("CalculatorRMIServer.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testCalculator() throws Exception { + // Calculate + calculatorService = (CalculatorService)Naming.lookup("//localhost:8099/CalculatorRMIService"); + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/README new file mode 100644 index 0000000000..ab1dda13df --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/README @@ -0,0 +1,105 @@ +Calculator Script Sample +======================== +This sample implements a simple calculator using SCA components implemented +using Java, JavaScript, Ruby, Python and Groovy. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-script.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-calculator-script.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. Each +component is implemented using a different language. + +calculator-script/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component calls +-/* as + appropriate + CalculatorServiceImpl.java + AddService.java - adds two numbers + SubtractService.java - subtracts one number from another + MultiplyService.java - multiplies two numbers + DivideService.java - divides one number by another + CalculatorClient.java - starts the SCA Runtime and + deploys the Calculator.composite. + It then calls the deployed Calculator + Components services + resources/ + calculator/ + AddServiceImpl.js - A JavaScript implementation of the + Add component + SubtractServiceImpl.rb - A Ruby implementation of the Subtract + component + MultiplyServiceImpl.py - A Python implementation of the + Multiple component + DivideServiceImpl.groovy- A Groovy implementation of the + Divide component + Calculator.composite - the SCA assembly for this sample + + test/ + java/ + calculator/ + CalculatorTestCase.java - JUnit test case + calculator-script.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-script +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-script +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: 5.918 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/build.xml new file mode 100644 index 0000000000..429d638ca5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.png new file mode 100644 index 0000000000..d3f8c491c3 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.svg new file mode 100644 index 0000000000..16939f9310 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/calculator-script.svg @@ -0,0 +1,334 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent(Java) + + + CalculatorService + AddServiceComponent(Javascript) + + SubtractServiceComponent(Ruby) + + MultiplyServiceComponent(Python) + + DivideServiceComponent(Groovy) + addService + subtractService + multiplyService + divideService + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/pom.xml new file mode 100644 index 0000000000..0178233717 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator-script + Apache Tuscany Calculator Sample implemented using scripting languages + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-script + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-interface-wsdl-xml + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..a235e648c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..243d1562dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package calculator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * 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 { + + SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); + CalculatorService calculatorService = + scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..ba897fa301 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..497dafd4fd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..376b3e5bb9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..8a765e6153 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/Calculator.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js new file mode 100644 index 0000000000..1d4d221364 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/AddServiceImpl.js @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +function add(n1, n2) { + return n1 + n2; +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy new file mode 100644 index 0000000000..c31c1e8fd6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/DivideServiceImpl.groovy @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +def divide(n1, n2) { + return n1 / n2 +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py new file mode 100644 index 0000000000..d6f27ca7f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/MultiplyServiceImpl.py @@ -0,0 +1,20 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +def multiply(n1, n2): + return n1 * n2 \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb new file mode 100644 index 0000000000..132a1d13b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/main/resources/calculator/SubtractServiceImpl.rb @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +def subtract(n1, n2) + return n1 - n2 +end \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..fea8f62110 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-script/src/test/java/calculator/CalculatorTestCase.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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("Calculator.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/README new file mode 100644 index 0000000000..0e97f4de33 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/README @@ -0,0 +1,117 @@ +Calculator Sample Exposing Web Services In A WebApp +=================================================== +This sample uses the same code as the calculator sample, it deploys the +sample wrapped in a web app and exposes the AddService as a web service. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-calculator-webapp.war) +to you web application server. + +***** +Note: this sample does not come with a pre-built WAR so you must first + build the sample by following the building instructions below +***** + +You may find that you need to remove the servlet-api jars in WEB-INF/lib +depending on which app server you are using. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8085/sample-calculator-webapp-ws/calc.jsp + +The port and hostname will of course vary depending on your local installation. + +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-webapp/ + 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 - As calculator sample + resources/ + Calculator.composite - As calculator sample except that the + connection between the CalculatorService + and the AddService is web services + webapp + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime and maps service + calls to the TuscanyServlet + calc.jsp - the web application that makes use of the + SCA application + 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 using Ant as +follows + +cd calculator-web +ant package + +This should result in a war file (sample-calculator-webapp.war) in the target +directory. Copy this war file to your web app deployment directory in you +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8085/sample-calculator-webapp/calc.jsp + +The port and hostname will of course vary depending on your local installation. + +You should see the following output. + +Expression Result +2 + 3 5.0 +3 - 2 1.0 +3 * 2 6.0 +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-web +mvn + +Again this should result in a war file (sample-calculator-webapp.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/build.xml new file mode 100644 index 0000000000..7c54e9607d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/build.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.png new file mode 100644 index 0000000000..f482b8d1c8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.svg new file mode 100644 index 0000000000..cccb797ba4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/calculator-web.svg @@ -0,0 +1,455 @@ + + + + + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + calc.jsp + + AppServer SOAP local local local + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/pom.xml new file mode 100644 index 0000000000..0b89ecbfa6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/pom.xml @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator-webapp-ws + war + Apache Tuscany Calculator Sample WebApp With WebServices + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-http-jetty + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..c3c789e745 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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.osoa.sca.annotations.Remotable; + +/** + * The interface for the add service + */ +@Remotable +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..a7049729f7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +import org.osoa.sca.annotations.Service; + +/** + * An implementation of the Add service + */ +@Service(AddService.class) +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + System.err.println("Adding " + n1 + " to " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..4787b728f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorClient.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 calculator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + * + * (not really necessary as this sample runs in a webapp) + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); + CalculatorService calculatorService = + scaDomain.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)); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..ce64b086ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/Calculator.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/wsdl/add.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/wsdl/add.wsdl new file mode 100644 index 0000000000..40a3d873d3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/resources/wsdl/add.wsdl @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..fe09ab2e1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..c9cde16f84 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,45 @@ + + + + + + + Tuscany Calculator Web Service Sample + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + TuscanyServlet + org.apache.tuscany.sca.host.webapp.TuscanyServlet + + + + TuscanyServlet + /services/* + + + + calc.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..375116e5de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp-ws/src/main/webapp/calc.jsp @@ -0,0 +1,50 @@ +<%-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--%> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> +<%@ page import="calculator.CalculatorService" %> + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<% + SCADomain scaDomain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain"); + CalculatorService calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); +%> + +Calculator sample + + + + + + + + + + + + + + + + + + +
ExpressionResult
2 + 3<%= calculatorService.add(2, 3) %>
3 - 2<%= calculatorService.subtract(3, 2) %>
3 * 2<%= calculatorService.multiply(3, 2) %>
3 / 2<%= calculatorService.divide(3, 2) %>
+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/README new file mode 100644 index 0000000000..c88b92b206 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/README @@ -0,0 +1,118 @@ +Calculator Sample +================= +This sample uses the same code as the calculator sample but deploys the +sample wrapped in a web app. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-calculator-webapp.war) +to you web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-calculator-webapp/calc.jsp + +The port and hostname will of course vary depending on your local installation. + +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-webapp/ + 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 - As calculator sample + resources/ + Calculator.composite - As calculator sample + webapp + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + calc.jsp - the web application that makes use of the + SCA application + 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 using Ant as +follows + +cd calculator-webapp +ant package + +This should result in a war file (sample-calculator-webapp.war) in the target +directory. Copy this war file to your web app deployment directory in you +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-calculator-webapp/calc.jsp + +The port and hostname will of course vary depending on your local installation. + +You should see the following output. + +Expression Result +2 + 3 5.0 +3 - 2 1.0 +3 * 2 6.0 +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-webapp +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: 0.852 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +Again this should result in a war file (sample-calculator-webapp.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/build.xml new file mode 100644 index 0000000000..3a39fe015c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/build.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.png new file mode 100644 index 0000000000..896ddc4093 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.svg new file mode 100644 index 0000000000..00ed27556f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/calculator-web.svg @@ -0,0 +1,358 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + WebApp + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/pom.xml new file mode 100644 index 0000000000..b851144656 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator-webapp + war + Apache Tuscany Calculator Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..ec57a6a533 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9c635e3c8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..4787b728f4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorClient.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 calculator; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + * + * (not really necessary as this sample runs in a webapp) + */ +public class CalculatorClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); + CalculatorService calculatorService = + scaDomain.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)); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..ad87375529 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..bf3b0303ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..835e4fda6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the divide service + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..8c33862f6d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..db568cc762 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..c7fbc73c00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..30e4e6a56a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package calculator; + +/** + * The interface for the subtract service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1a7f145ad8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..50c23af0b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..fe09ab2e1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..a37b430860 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,35 @@ + + + + + + + Tuscany Calculator Web Service Sample + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + calc.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/calc.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/calc.jsp new file mode 100644 index 0000000000..375116e5de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/main/webapp/calc.jsp @@ -0,0 +1,50 @@ +<%-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. +--%> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> +<%@ page import="calculator.CalculatorService" %> + +<%@ page contentType="text/html;charset=UTF-8" language="java" %> +<% + SCADomain scaDomain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain"); + CalculatorService calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); +%> + +Calculator sample + + + + + + + + + + + + + + + + + + +
ExpressionResult
2 + 3<%= calculatorService.add(2, 3) %>
3 - 2<%= calculatorService.subtract(3, 2) %>
3 * 2<%= calculatorService.multiply(3, 2) %>
3 / 2<%= calculatorService.divide(3, 2) %>
+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..4ce3acf46a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator-webapp/src/test/java/calculator/CalculatorTestCase.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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorTestCase extends TestCase { + + private SCADomain scaDomain; + private CalculatorService calculatorService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("Calculator.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/README b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/README new file mode 100644 index 0000000000..ceb532faed --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator.jar calculator.CalculatorClient + +and on *nix do + +java -cp ../../lib/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/build.xml new file mode 100644 index 0000000000..c4b755ef94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.png b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.png new file mode 100644 index 0000000000..995a57b1fd Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.svg b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/calculator.svg new file mode 100644 index 0000000000..0615925c50 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/pom.xml new file mode 100644 index 0000000000..0d652f5622 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-calculator + Apache Tuscany Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..8b6fe066a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..9d180bf52e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorClient.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.host.embedded.SCADomain; + +/** + * 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 { + + SCADomain scaDomain = SCADomain.newInstance("Calculator.composite"); + + CalculatorService calculatorService = + scaDomain.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)); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..3d861f2018 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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.osoa.sca.annotations.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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractService.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..77b128ab8d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/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/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/resources/Calculator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/resources/Calculator.composite new file mode 100644 index 0000000000..90872041b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/main/resources/Calculator.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/test/java/calculator/CalculatorTestCase.java new file mode 100644 index 0000000000..a5735a8701 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/calculator/src/test/java/calculator/CalculatorTestCase.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 junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This shows how to test the Calculator service component. + */ +public class CalculatorTestCase extends TestCase { + + private CalculatorService calculatorService; + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("Calculator.composite"); + calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testCalculator() throws Exception { + // Calculate + assertEquals(calculatorService.add(3, 2), 5.0); + assertEquals(calculatorService.subtract(3, 2), 1.0); + assertEquals(calculatorService.multiply(3, 2), 6.0); + assertEquals(calculatorService.divide(3, 2), 1.5); + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/README b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/README new file mode 100644 index 0000000000..dddd7e3f94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/README @@ -0,0 +1,61 @@ +Chat WebApp Sample +================== +This sample demonstrates the SCA DWR binding to implement the classic Ajax sample +of a chat application which allows multiple users to chat from their browsers. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-chat-webapp.war) +to your web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-chat-webapp + +The port and hostname will of course vary depending on your local installation. + +Sample Overview +--------------- +The sample provides an SCA component which has an SCA service using the SCA DWR +binding and an SCA reference also using the DWR binding. The component implementation +simply forwards every invocation of the service as an invocation on the reference. The +component reference is scoped by the composite so every active client of the composite +will receive every message sent to the component service, thus implementing the chat +application with very little code. + +chat-webapp/ + src/ + main/ + java/ + sample/ + ChatService.java - service interface + ChatServiceImpl.java - service implementation + resources/ + chat.composite - the SCA assembly for this sample + webapp + chat.html - the html UserInterface for this application + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + + pom.xml - the Maven build file + +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 chat-webapp +mvn + +Again this should result in a war file (sample-chat-webapp.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/build.xml new file mode 100644 index 0000000000..1fba79520f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/build.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/pom.xml new file mode 100644 index 0000000000..7b749de6ae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-chat-webapp + war + Apache Tuscany Chat Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-binding-dwr + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatService.java b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatService.java new file mode 100644 index 0000000000..1fb9d292cd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatService.java @@ -0,0 +1,28 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package sample; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Service +@Remotable +public interface ChatService { + + public void chat(String msg); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java new file mode 100644 index 0000000000..7d0bfb3307 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/java/sample/ChatServiceImpl.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class ChatServiceImpl implements ChatService { + + ChatService chatters; + + public void chat(String msg) { + chatters.chat(msg); + } + + public void setChatters(ChatService chatters) { + this.chatters = chatters; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/resources/chat.composite b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/resources/chat.composite new file mode 100644 index 0000000000..c9ce95e2dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/resources/chat.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..897849ff8d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..65d486a215 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,42 @@ + + + + + + Tuscany Chat Sample + + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + TuscanyServlet + org.apache.tuscany.sca.host.webapp.TuscanyServlet + + + + TuscanyServlet + /SCA/* + + + + chat.html + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/chat.html b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/chat.html new file mode 100644 index 0000000000..fc80921e48 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/chat-webapp/src/main/webapp/chat.html @@ -0,0 +1,70 @@ + + + + Tuscany Ajax/DWR Chat Sample + + + + + + + + +

Tuscany Ajax/DWR Chat Sample

+ + A simple client to chat between multiple web browsers:

+ + Nickname: +

+ + Enter text: + + +

+
+ + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/build.xml new file mode 100644 index 0000000000..feef76481b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/build.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/db.lck b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/db.lck new file mode 100644 index 0000000000..9f6b4b3d4b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/db.lck differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log.ctrl b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log.ctrl new file mode 100644 index 0000000000..edbd775299 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log.ctrl differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log1.dat new file mode 100644 index 0000000000..7e85ac8e8f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/log1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/logmirror.ctrl b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/logmirror.ctrl new file mode 100644 index 0000000000..edbd775299 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/log/logmirror.ctrl differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c10.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c10.dat new file mode 100644 index 0000000000..5d8ecaa10f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c10.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c101.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c101.dat new file mode 100644 index 0000000000..0f79fa7574 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c101.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c111.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c111.dat new file mode 100644 index 0000000000..39d49e3d19 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c111.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c121.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c121.dat new file mode 100644 index 0000000000..2a4311779b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c121.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c130.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c130.dat new file mode 100644 index 0000000000..64e3c18d62 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c130.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c141.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c141.dat new file mode 100644 index 0000000000..0632d04164 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c141.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c150.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c150.dat new file mode 100644 index 0000000000..d7541026f6 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c150.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c161.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c161.dat new file mode 100644 index 0000000000..6673bf1873 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c161.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c171.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c171.dat new file mode 100644 index 0000000000..c2a753cc5d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c171.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c180.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c180.dat new file mode 100644 index 0000000000..cb9391aed1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c180.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c191.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c191.dat new file mode 100644 index 0000000000..d3cf1d6364 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c191.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1a1.dat new file mode 100644 index 0000000000..a7a2d536e9 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1b1.dat new file mode 100644 index 0000000000..19097e69e7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1c0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1c0.dat new file mode 100644 index 0000000000..359525a31a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1c0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1d1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1d1.dat new file mode 100644 index 0000000000..9f257df932 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1d1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1e0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1e0.dat new file mode 100644 index 0000000000..e43e52fb7f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1e0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1f1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1f1.dat new file mode 100644 index 0000000000..7e6ee3b1e0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c1f1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c20.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c20.dat new file mode 100644 index 0000000000..1be6390f06 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c20.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c200.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c200.dat new file mode 100644 index 0000000000..b15d56855c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c200.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c211.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c211.dat new file mode 100644 index 0000000000..84b0022312 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c211.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c221.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c221.dat new file mode 100644 index 0000000000..63106a9523 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c221.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c230.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c230.dat new file mode 100644 index 0000000000..9975f27c1f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c230.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c241.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c241.dat new file mode 100644 index 0000000000..835c645a16 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c241.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c251.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c251.dat new file mode 100644 index 0000000000..d3d6adf4fb Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c251.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c260.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c260.dat new file mode 100644 index 0000000000..8d7333df7d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c260.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c271.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c271.dat new file mode 100644 index 0000000000..af722f7d73 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c271.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c281.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c281.dat new file mode 100644 index 0000000000..3972983c2e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c281.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c290.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c290.dat new file mode 100644 index 0000000000..31577b8124 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c290.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2a1.dat new file mode 100644 index 0000000000..0f700d13a7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2b1.dat new file mode 100644 index 0000000000..1d6382fb3d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2c1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2c1.dat new file mode 100644 index 0000000000..3bc60d886b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2c1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2d0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2d0.dat new file mode 100644 index 0000000000..c542d3c91c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2d0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2e1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2e1.dat new file mode 100644 index 0000000000..16abd20b5f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2e1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2f0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2f0.dat new file mode 100644 index 0000000000..eb26be5932 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c2f0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c300.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c300.dat new file mode 100644 index 0000000000..1214f1df4b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c300.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c31.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c31.dat new file mode 100644 index 0000000000..18c16f1123 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c31.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c311.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c311.dat new file mode 100644 index 0000000000..926cbf25b5 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c311.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c320.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c320.dat new file mode 100644 index 0000000000..07e7bc023c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c320.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c331.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c331.dat new file mode 100644 index 0000000000..fd827f9dc2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c331.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c340.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c340.dat new file mode 100644 index 0000000000..ca70319886 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c340.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c351.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c351.dat new file mode 100644 index 0000000000..8fbe2a527c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c351.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c360.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c360.dat new file mode 100644 index 0000000000..dcf9c746e1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c360.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c371.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c371.dat new file mode 100644 index 0000000000..6f21a840ea Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c371.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c380.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c380.dat new file mode 100644 index 0000000000..b512e8065f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c380.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c391.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c391.dat new file mode 100644 index 0000000000..27006e95a1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c391.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3a0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3a0.dat new file mode 100644 index 0000000000..565dca97ac Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3a0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3b1.dat new file mode 100644 index 0000000000..36894c9818 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3c0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3c0.dat new file mode 100644 index 0000000000..d0c538aede Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3c0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3d1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3d1.dat new file mode 100644 index 0000000000..65bcec5527 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3d1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3e0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3e0.dat new file mode 100644 index 0000000000..bdab359420 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3e0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3f1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3f1.dat new file mode 100644 index 0000000000..dc2d278b57 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c3f1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c400.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c400.dat new file mode 100644 index 0000000000..3072709cec Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c400.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c41.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c41.dat new file mode 100644 index 0000000000..61086690f2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c41.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c411.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c411.dat new file mode 100644 index 0000000000..ca551d8249 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c411.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c420.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c420.dat new file mode 100644 index 0000000000..f04de0840e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c420.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c431.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c431.dat new file mode 100644 index 0000000000..398b1672cc Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c431.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c440.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c440.dat new file mode 100644 index 0000000000..af259d0872 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c440.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c451.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c451.dat new file mode 100644 index 0000000000..772a18c658 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c451.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c460.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c460.dat new file mode 100644 index 0000000000..505428362d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c460.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c471.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c471.dat new file mode 100644 index 0000000000..484d0df42d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c471.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c481.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c481.dat new file mode 100644 index 0000000000..faac073076 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c481.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c490.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c490.dat new file mode 100644 index 0000000000..7585319d21 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c490.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c4a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c4a1.dat new file mode 100644 index 0000000000..4fe8b786e3 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c4a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c51.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c51.dat new file mode 100644 index 0000000000..7fc7937b15 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c51.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c60.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c60.dat new file mode 100644 index 0000000000..d1fb08c946 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c60.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c71.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c71.dat new file mode 100644 index 0000000000..d4c2090a3b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c71.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c81.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c81.dat new file mode 100644 index 0000000000..38b6ea6520 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c81.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c90.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c90.dat new file mode 100644 index 0000000000..a607a5969c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/c90.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ca1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ca1.dat new file mode 100644 index 0000000000..19b4c9e340 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ca1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cb1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cb1.dat new file mode 100644 index 0000000000..73dc986572 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cb1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cc0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cc0.dat new file mode 100644 index 0000000000..d1eef3bb56 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cc0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cd1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cd1.dat new file mode 100644 index 0000000000..c7e6db3ef7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cd1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ce1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ce1.dat new file mode 100644 index 0000000000..8fd3bf17a8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/ce1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cf0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cf0.dat new file mode 100644 index 0000000000..332b3d9a8a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/seg0/cf0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/service.properties b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/service.properties new file mode 100644 index 0000000000..af9511d9c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/dastest/service.properties @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#C:\apacheSVN\java\target\dastest +# ******************************************************************** +# *** Please do NOT edit this file. *** +# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. *** +# ******************************************************************** +#Fri Feb 17 08:55:29 MST 2006 +SysschemasIndex2Identifier=225 +SyscolumnsIdentifier=144 +SysconglomeratesIndex1Identifier=49 +SysconglomeratesIdentifier=32 +SyscolumnsIndex2Identifier=177 +SysschemasIndex1Identifier=209 +SysconglomeratesIndex3Identifier=81 +SystablesIndex2Identifier=129 +SyscolumnsIndex1Identifier=161 +derby.serviceProtocol=org.apache.derby.database.Database +SysschemasIdentifier=192 +derby.storage.propertiesId=16 +SysconglomeratesIndex2Identifier=65 +derby.serviceLocale=en_US +SystablesIdentifier=96 +SystablesIndex1Identifier=113 diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/pom.xml new file mode 100644 index 0000000000..db6a6426cc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../pom.xml + + + sample-company-das-webapp + Apache Tuscany DAS Data Access Service Web Client Sample + war + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + + org.apache.tuscany.das + tuscany-das-rdb + 1.0-incubating-SNAPSHOT + compile + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + compile + + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + src/main/java + + + src/main/java + + + src/main/resources + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/readme.html b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/readme.html new file mode 100644 index 0000000000..65a50de320 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/readme.html @@ -0,0 +1,199 @@ + + + + + +Tuscany RDB DAS Service client + + + + + + + + + + +

Tuscany RDB DAS Service client

+ + +

Introduction

+ +

+This stand-alone sample application demonstrate how to consume the DAS Service exposed trough an SCA service.
+The application starts with a canned database of Companies and their related Departments.
+Through the web page interface, a user can consume the DAS Service to display the list of available companies.
+The sample runs on Tomcat 5.5 and employs a Derby database accessed via a DataSource. +

+ + + + + +

Running the sample

+ +

There are two options for running this sample:

+ +
    +
  1. Run from Tomcat configured by the build
  2. +
  3. Deploying the DASService.client WAR into a Tomcat you configure yourself
  4. +
+ + +

Running from Tomcat configured by the build

+ +

+This sample application is deployed (along with the canned test database) to an instance of Tomcat as part of our automated sample +testing.This means you can run the java/samples/testing/tomcat build (see java/das/samples/testing/tomcat/readme.htm ) and then access +the application by pointing your browser to http://localhost:8080/companyweb-service-client/ +

+ + + +

Deploying the DASService.client WAR into a Tomcat you configure yourself

+ +

+Alternatively, you can deploy the sample to your own configured Tomcat installation by following the instructions below. +These instructions assume that you have either 1) downloaded the Tuscany sample distribution or 2) Downloaded the Tuscany +source and run our maven build, see the following link to more details steps on how to build DAS Sample applications http://incubator.apache.org/tuscany/java_das_overview.html. +

+ +

Set Up:

+ + +
    +
  1. Download and install the most recent stable version of Tomcat 5.5. You can find it here: http://tomcat.apache.org/download-55.cgi
  2. +
  3. Download the most recent official release of Derby from here: http://db.apache.org/derby/index.html. + The only file you’ll need from this download is derby.jar
  4. +
  5. Stop Tomcat
  6. +
  7. Copy derby.jar (from the derby distribution) to {Tomcat_Home}/common/lib:
  8. +
  9. Add the sample war file to {Tomcat_Home}/webapps
  10. +
      +
    1. sample-das-service-client-xxx.war (e.g.sample-das-service-client-1.0-incubator-SNAPSHOT.war)
    2. +
    +
  11. Install the canned Derby database to Tomcat:
  12. +
      +
    1. First, create a new directory named “Databases” to hold the sample database. Create {Tomcat_Home}/Databases
    2. +
    3. Copy the dastest folder (and all its contents) from {build directory root OR + where samples where unzipped}/java/das/samples/DASService.client to {Tomcat_Home}/Databases.
      +
      + NOTE: If you are running this from a sample distribution, the canned database is available in the + distribution, inside the databases directory.
    4. +
    +
  13. Define a DataSource by adding a datasource definition to {Tomcat_Home}/conf/server.xml.
  14. +
      +
    1. Find the end-of-section marker </GlobalNamingResources> and add the following lines just above it: +

      +

      +
      +         <!-- Global Datasource for Derby dastest database -->
      +         <Resource name="jdbc/dastest"
      +              type="javax.sql.DataSource"  auth="Container"
      +              description="Derby database for DAS Company sample"
      +              maxActive="100" maxIdle="30" maxWait="10000"
      +              username="" password=""
      +              driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
      +              url="jdbc:derby:{absolute path}Databases/dastest"/>
      +      
      +
      +

      +

      Requirement:You must include the absolute path to the “Databases” directory in the above url attribute. Fore example:

      +

      	url="jdbc:derby:c:\apache-tomcat-5.5.17\Databases/dastest"

      +
    2. +
    +
  15. Start tomcat and point your browser to: http://localhost:8080/sample-das-service-client-{version + tag}/. Example:

    +

    	http://localhost:8080/sample-das-service-client-1.0-incubator-SNAPSHOT/

    + +
  16. + +
+ + + + +

Sample Architecture

+ +

This is a simple, single-page, web application to consume DAS exposed as an SCA service.

+

The main components of this application are:

+ +
    +
  • The SCA DAS Service
  • +
  • SDO
  • +
  • Company.jsp
  • +
  • The canned Derby database
  • +
+ + +

The Company.jsp directly invoke the DAS Service to get a list of companies available and then iterate trough the SDO data graphs and manipulate SDO directly to display data

+ +

The canned Derby database comes preloaded with Companies and related Departments. The Derby database instance is a simple file folder.

+ +

The SCA DAS Service accepts directives (commands) and reads and writes to the derby database instance appropriately using DAS as the service implementation.

+ + + +

Consuming the DAS service

+ +

First, note that the application have dependencies on the DAS Service:

+ + +

+

+
+<!-- DAS Service -->
+<dependency>
+   <groupId>org.apache.tuscany.das.samples</groupId>
+   <artifactId>sample-das-service</artifactId>
+   <version>${pom.version}</version>
+</dependency>
+
+
+

+ +
+

And the SCDL references the service:

+ +

+

+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="DASServiceComposite">
+  <component name="DASServiceComponent">
+     <implementation.composite name="DASServiceComposite" jarLocation="lib/sample-das-service-1.0-incubator-SNAPSHOT.jar"/>
+  </component>
+</composite>
+
+
+

+ + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASService.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASService.java new file mode 100644 index 0000000000..0387341b87 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASService.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +import java.io.InputStream; +import java.util.Vector; + +import commonj.sdo.DataObject; + +public interface DASService { + + /** + * Set DAS configuration file to be used + * @param configStream + * @throws DASServiceException + */ + public void configureService(InputStream configStream) throws DASServiceException; + + /** + * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service + * @param commandName Command name as it appears on the DAS Configuration file + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException; + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param adHocQuery A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException; + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @param graphRoot SDO Object with changes to be commited to persistent repository + * @throws DASServiceException + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException; +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceException.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceException.java new file mode 100644 index 0000000000..e62201a4de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceException.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +public class DASServiceException extends Exception { + + private static final long serialVersionUID = -7514653215235902874L; + + public DASServiceException() { + super(); + } + + public DASServiceException(String msg) { + super(msg); + } + + public DASServiceException(String msg, Throwable ex) { + super(msg, ex); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceImpl.java new file mode 100644 index 0000000000..70d9e379ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/java/das/DASServiceImpl.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +import java.io.InputStream; +import java.util.Vector; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.DAS; +import org.osoa.sca.annotations.Scope; + +import commonj.sdo.DataObject; + +@Scope("COMPOSITE") +public class DASServiceImpl implements DASService { + + protected DAS das = null; + + + /** + * Initialize DAS + * @return + * @throws DASServiceException + */ + private void initDAS(InputStream config) throws DASServiceException { + if(config == null){ + throw new DASServiceException("Missing configuration information"); + } + + if(this.das != null){ + this.das.releaseResources(); + this.das = null; + } + + this.das = DAS.FACTORY.createDAS(config); + } + + /** + * Get a DAS instance based on the configuration + * @return + * @throws DASServiceException + */ + private DAS getDAS() throws DASServiceException { + if(this.das == null){ + throw new DASServiceException("DAS not initialized. Please provide DAS configuration torugh das.SetConfig"); + } + + return this.das; + } + + /** + * Set DAS configuration file to be used + * @param configStream + * @throws DASServiceException + */ + public void configureService(InputStream configStream) throws DASServiceException{ + this.initDAS(configStream); + } + + + + /** + * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service + * @param commandName Command name as it appears on the DAS Configuration file + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException{ + Command command = this.getDAS().getCommand(commandName); + + if(command == null){ + throw new DASServiceException("Invalid command: " + commandName); + } + + //check if arguments was passed + if(commandArguments != null && commandArguments.size() > 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param newCommand A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException { + Command command = this.getDAS().createCommand(adHocQuery); + + if(command == null){ + throw new DASServiceException("Invalid command: " + adHocQuery); + } + + //check if arguments was passed + if(commandArguments != null && commandArguments.size() > 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @throws DASServiceException + * @param graphRoot SDO Object with changes to be commited to persistent repository + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException{ + // TODO Auto-generated method stub + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/CompanyConfig.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/CompanyConfig.xml new file mode 100644 index 0000000000..3d20054c12 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/CompanyConfig.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/dasservice.composite b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/dasservice.composite new file mode 100644 index 0000000000..54c4af61ee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/dasservice.composite @@ -0,0 +1,34 @@ + + + + + + + DASServiceComponent + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/log4j.properties b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/log4j.properties new file mode 100644 index 0000000000..c5c2868aaa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/resources/log4j.properties @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=INFO, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=[DAS RDB] - %c{1}.%M (%L) : %m %n + +# Print only messages of level WARN or above in the package com.foo. +log4j.logger.org.apache.tuscany=NONE \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/Company.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/Company.jsp new file mode 100644 index 0000000000..0a156de1c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/Company.jsp @@ -0,0 +1,93 @@ + + + +<%@ page import="java.util.*" %> + +<%@ page import="org.apache.tuscany.sca.host.embedded.SCADomain"%> + +<%@ page import="commonj.sdo.*" %> +<%@ page import="das.*" %> + + + +<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> +<% + + SCADomain domain = (SCADomain) application.getAttribute("org.apache.tuscany.sca.SCADomain"); + if (domain == null) { + System.out.println("domain == NULL"); + } + + + DASService dasService = domain.getService(DASService.class, "DASServiceComponent"); + + if (dasService == null) { + System.out.println("DASService == NULL"); + } + + List companyList = null; + + try{ + dasService.configureService(getClass().getClassLoader().getResourceAsStream("CompanyConfig.xml")); + DataObject root = dasService.executeCommand("all companies", null); + companyList = root.getList("COMPANY"); + }catch(Exception e){ + //TODO: handle case where dasService can't be initiated properly + } + +%> + + +DASService Client Test + + + +

Tuscany DAS Service WEB Client Application Example

+ + + + + + + + + + + + <% + java.util.Iterator i = companyList.iterator(); + while (i.hasNext()) { + DataObject company = (DataObject)i.next(); + %> + + + + + <% + } + %> + +
IDName
<%=company.getInt("ID")%><%=company.getString("NAME")%>
+ + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/context.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/context.xml new file mode 100644 index 0000000000..0e90eb0a83 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/context.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..25849fa6b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..67a782269e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,35 @@ + + + + + + + Tuscany DAS Service Client Application + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + Company.jsp + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/pom.xml new file mode 100644 index 0000000000..ce1858c19c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/pom.xml @@ -0,0 +1,99 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../pom.xml + + + sample-company-das + Apache Tuscany Company Data Access Service Sample + jar + + + + + org.apache.tuscany.sca + sca-api + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + compile + + + + org.apache.tuscany.das + tuscany-das-rdb + 1.0-incubating-SNAPSHOT + compile + + + + org.apache.derby + derby + 10.1.2.1 + test + + + + junit + junit + 4.2 + test + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.apache.tuscany.samples.das.service.client.DASServiceClient + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/readme.html b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/readme.html new file mode 100644 index 0000000000..ec6b492b72 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/readme.html @@ -0,0 +1,110 @@ + + + + + +Tuscany RDB DAS exposed as an SCA service + + + + + + + + + + +

Tuscany RDB DAS exposed as an SCA service

+ + +

Introduction

+ +

This is a sample SCA service that exposes DAS functionality.

+

This service would allow you to utilize DAS in a language neutral fashion, consuming existent or adHoc commands.

+ + +

Consuming the DAS service

+ + +

You should add the dependency on your client project pom file

+ + +

+

+
+<!-- DAS Service -->
+<dependency>
+   <groupId>org.apache.tuscany.das.samples</groupId>
+   <artifactId>sample-das-service</artifactId>
+   <version>${pom.version}</version>
+</dependency>
+
+
+

+ +
+

In order to consume the service, you would have to create a SCDL that references it, see sample below:

+ +

+

+
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="DASServiceComposite">
+  <component name="DASServiceComponent">
+     <implementation.composite name="DASServiceComposite" jarLocation="lib/sample-das-service-1.0-incubator-SNAPSHOT.jar"/>
+  </component>
+</composite>
+
+
+

+ + +

Sample Architecture

+ +

This service utilizes the following Interface as its definition:

+ + +

+

+
+
+public interface DASService {
+
+    public void configureService(InputStream configStream) throws DASServiceException;
+
+    public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException;
+
+    public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException;
+
+    public void applyChanges(DataObject graphRoot) throws DASServiceException;
+
+}
+
+
+

+ + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASService.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASService.java new file mode 100644 index 0000000000..0387341b87 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASService.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +import java.io.InputStream; +import java.util.Vector; + +import commonj.sdo.DataObject; + +public interface DASService { + + /** + * Set DAS configuration file to be used + * @param configStream + * @throws DASServiceException + */ + public void configureService(InputStream configStream) throws DASServiceException; + + /** + * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service + * @param commandName Command name as it appears on the DAS Configuration file + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException; + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param adHocQuery A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException; + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @param graphRoot SDO Object with changes to be commited to persistent repository + * @throws DASServiceException + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException; +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceException.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceException.java new file mode 100644 index 0000000000..e62201a4de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceException.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +public class DASServiceException extends Exception { + + private static final long serialVersionUID = -7514653215235902874L; + + public DASServiceException() { + super(); + } + + public DASServiceException(String msg) { + super(msg); + } + + public DASServiceException(String msg, Throwable ex) { + super(msg, ex); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceImpl.java new file mode 100644 index 0000000000..70d9e379ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/java/das/DASServiceImpl.java @@ -0,0 +1,146 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +import java.io.InputStream; +import java.util.Vector; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.DAS; +import org.osoa.sca.annotations.Scope; + +import commonj.sdo.DataObject; + +@Scope("COMPOSITE") +public class DASServiceImpl implements DASService { + + protected DAS das = null; + + + /** + * Initialize DAS + * @return + * @throws DASServiceException + */ + private void initDAS(InputStream config) throws DASServiceException { + if(config == null){ + throw new DASServiceException("Missing configuration information"); + } + + if(this.das != null){ + this.das.releaseResources(); + this.das = null; + } + + this.das = DAS.FACTORY.createDAS(config); + } + + /** + * Get a DAS instance based on the configuration + * @return + * @throws DASServiceException + */ + private DAS getDAS() throws DASServiceException { + if(this.das == null){ + throw new DASServiceException("DAS not initialized. Please provide DAS configuration torugh das.SetConfig"); + } + + return this.das; + } + + /** + * Set DAS configuration file to be used + * @param configStream + * @throws DASServiceException + */ + public void configureService(InputStream configStream) throws DASServiceException{ + this.initDAS(configStream); + } + + + + /** + * Execute an existing command. The commands are defined in the DAS Configuration file being used by the service + * @param commandName Command name as it appears on the DAS Configuration file + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject executeCommand(String commandName, Vector commandArguments) throws DASServiceException{ + Command command = this.getDAS().getCommand(commandName); + + if(command == null){ + throw new DASServiceException("Invalid command: " + commandName); + } + + //check if arguments was passed + if(commandArguments != null && commandArguments.size() > 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Execute a new command, this can be any arbitrary valid query based on the backend implementation (e.g. SQL Query for DAS RDB) + * @param newCommand A new command to be executed (e.g SQL Query) + * @param commandArguments Vector with arguments to be used by the command + * @throws DASServiceException + * @return + */ + public DataObject execute(String adHocQuery, Vector commandArguments) throws DASServiceException { + Command command = this.getDAS().createCommand(adHocQuery); + + if(command == null){ + throw new DASServiceException("Invalid command: " + adHocQuery); + } + + //check if arguments was passed + if(commandArguments != null && commandArguments.size() > 0){ + //we need to set the arguments + int pos=0; + for(Object argument : commandArguments){ + pos++; + command.setParameter(pos, argument); + } + } + DataObject root = command.executeQuery(); + + return root; + } + + /** + * Apply all changes on the graph back to the persistent repository. + * This would save the changes on the SDO ChangeSummary back to the database + * Note: Your SDO ojects should have been created with ChangeSummary support + * @throws DASServiceException + * @param graphRoot SDO Object with changes to be commited to persistent repository + */ + public void applyChanges(DataObject graphRoot) throws DASServiceException{ + // TODO Auto-generated method stub + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/resources/dasservice.composite b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/resources/dasservice.composite new file mode 100644 index 0000000000..42ac52a756 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/main/resources/dasservice.composite @@ -0,0 +1,34 @@ + + + + + + + DASServiceComponent + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/java/das/DASServiceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/java/das/DASServiceTestCase.java new file mode 100644 index 0000000000..38acde3eb0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/java/das/DASServiceTestCase.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package das; + +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import commonj.sdo.DataObject; + +public class DASServiceTestCase extends TestCase { + + SCADomain scaDomain; + private DASService dasService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("dasservice.composite"); + dasService = scaDomain.getService(DASService.class, "DASServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testDAS() throws Exception{ + dasService.configureService(getClass().getResourceAsStream("/CompanyConfig.xml")); + DataObject root = dasService.executeCommand("all companies", null); + List companyList = root.getList("COMPANY"); + + assertNotNull(companyList); + assertEquals(3,companyList.size()); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/CompanyConfig.xml b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/CompanyConfig.xml new file mode 100644 index 0000000000..912e81e9f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/CompanyConfig.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + + + + +
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/db.lck b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/db.lck new file mode 100644 index 0000000000..9f6b4b3d4b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/db.lck differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log.ctrl b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log.ctrl new file mode 100644 index 0000000000..edbd775299 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log.ctrl differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log1.dat new file mode 100644 index 0000000000..7e85ac8e8f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/log1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/logmirror.ctrl b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/logmirror.ctrl new file mode 100644 index 0000000000..edbd775299 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/log/logmirror.ctrl differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c10.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c10.dat new file mode 100644 index 0000000000..5d8ecaa10f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c10.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c101.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c101.dat new file mode 100644 index 0000000000..0f79fa7574 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c101.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c111.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c111.dat new file mode 100644 index 0000000000..39d49e3d19 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c111.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c121.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c121.dat new file mode 100644 index 0000000000..2a4311779b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c121.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c130.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c130.dat new file mode 100644 index 0000000000..64e3c18d62 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c130.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c141.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c141.dat new file mode 100644 index 0000000000..0632d04164 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c141.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c150.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c150.dat new file mode 100644 index 0000000000..d7541026f6 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c150.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c161.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c161.dat new file mode 100644 index 0000000000..6673bf1873 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c161.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c171.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c171.dat new file mode 100644 index 0000000000..c2a753cc5d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c171.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c180.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c180.dat new file mode 100644 index 0000000000..cb9391aed1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c180.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c191.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c191.dat new file mode 100644 index 0000000000..d3cf1d6364 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c191.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1a1.dat new file mode 100644 index 0000000000..a7a2d536e9 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1b1.dat new file mode 100644 index 0000000000..19097e69e7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1c0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1c0.dat new file mode 100644 index 0000000000..359525a31a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1c0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1d1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1d1.dat new file mode 100644 index 0000000000..9f257df932 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1d1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1e0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1e0.dat new file mode 100644 index 0000000000..e43e52fb7f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1e0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1f1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1f1.dat new file mode 100644 index 0000000000..7e6ee3b1e0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c1f1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c20.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c20.dat new file mode 100644 index 0000000000..1be6390f06 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c20.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c200.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c200.dat new file mode 100644 index 0000000000..b15d56855c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c200.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c211.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c211.dat new file mode 100644 index 0000000000..84b0022312 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c211.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c221.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c221.dat new file mode 100644 index 0000000000..63106a9523 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c221.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c230.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c230.dat new file mode 100644 index 0000000000..9975f27c1f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c230.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c241.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c241.dat new file mode 100644 index 0000000000..835c645a16 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c241.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c251.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c251.dat new file mode 100644 index 0000000000..d3d6adf4fb Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c251.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c260.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c260.dat new file mode 100644 index 0000000000..8d7333df7d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c260.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c271.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c271.dat new file mode 100644 index 0000000000..af722f7d73 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c271.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c281.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c281.dat new file mode 100644 index 0000000000..3972983c2e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c281.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c290.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c290.dat new file mode 100644 index 0000000000..31577b8124 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c290.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2a1.dat new file mode 100644 index 0000000000..0f700d13a7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2b1.dat new file mode 100644 index 0000000000..1d6382fb3d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2c1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2c1.dat new file mode 100644 index 0000000000..3bc60d886b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2c1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2d0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2d0.dat new file mode 100644 index 0000000000..c542d3c91c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2d0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2e1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2e1.dat new file mode 100644 index 0000000000..16abd20b5f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2e1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2f0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2f0.dat new file mode 100644 index 0000000000..eb26be5932 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c2f0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c300.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c300.dat new file mode 100644 index 0000000000..1214f1df4b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c300.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c31.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c31.dat new file mode 100644 index 0000000000..18c16f1123 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c31.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c311.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c311.dat new file mode 100644 index 0000000000..926cbf25b5 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c311.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c320.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c320.dat new file mode 100644 index 0000000000..07e7bc023c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c320.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c331.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c331.dat new file mode 100644 index 0000000000..fd827f9dc2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c331.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c340.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c340.dat new file mode 100644 index 0000000000..ca70319886 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c340.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c351.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c351.dat new file mode 100644 index 0000000000..8fbe2a527c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c351.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c360.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c360.dat new file mode 100644 index 0000000000..dcf9c746e1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c360.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c371.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c371.dat new file mode 100644 index 0000000000..6f21a840ea Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c371.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c380.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c380.dat new file mode 100644 index 0000000000..b512e8065f Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c380.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c391.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c391.dat new file mode 100644 index 0000000000..27006e95a1 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c391.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3a0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3a0.dat new file mode 100644 index 0000000000..565dca97ac Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3a0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3b1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3b1.dat new file mode 100644 index 0000000000..36894c9818 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3b1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3c0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3c0.dat new file mode 100644 index 0000000000..d0c538aede Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3c0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3d1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3d1.dat new file mode 100644 index 0000000000..65bcec5527 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3d1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3e0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3e0.dat new file mode 100644 index 0000000000..bdab359420 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3e0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3f1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3f1.dat new file mode 100644 index 0000000000..dc2d278b57 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c3f1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c400.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c400.dat new file mode 100644 index 0000000000..3072709cec Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c400.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c41.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c41.dat new file mode 100644 index 0000000000..61086690f2 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c41.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c411.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c411.dat new file mode 100644 index 0000000000..ca551d8249 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c411.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c420.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c420.dat new file mode 100644 index 0000000000..f04de0840e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c420.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c431.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c431.dat new file mode 100644 index 0000000000..398b1672cc Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c431.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c440.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c440.dat new file mode 100644 index 0000000000..af259d0872 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c440.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c451.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c451.dat new file mode 100644 index 0000000000..772a18c658 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c451.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c460.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c460.dat new file mode 100644 index 0000000000..505428362d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c460.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c471.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c471.dat new file mode 100644 index 0000000000..484d0df42d Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c471.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c481.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c481.dat new file mode 100644 index 0000000000..faac073076 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c481.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c490.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c490.dat new file mode 100644 index 0000000000..7585319d21 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c490.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c4a1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c4a1.dat new file mode 100644 index 0000000000..4fe8b786e3 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c4a1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c51.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c51.dat new file mode 100644 index 0000000000..7fc7937b15 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c51.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c60.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c60.dat new file mode 100644 index 0000000000..d1fb08c946 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c60.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c71.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c71.dat new file mode 100644 index 0000000000..d4c2090a3b Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c71.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c81.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c81.dat new file mode 100644 index 0000000000..38b6ea6520 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c81.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c90.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c90.dat new file mode 100644 index 0000000000..a607a5969c Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/c90.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ca1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ca1.dat new file mode 100644 index 0000000000..19b4c9e340 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ca1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cb1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cb1.dat new file mode 100644 index 0000000000..73dc986572 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cb1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cc0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cc0.dat new file mode 100644 index 0000000000..d1eef3bb56 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cc0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cd1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cd1.dat new file mode 100644 index 0000000000..c7e6db3ef7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cd1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ce1.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ce1.dat new file mode 100644 index 0000000000..8fd3bf17a8 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/ce1.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cf0.dat b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cf0.dat new file mode 100644 index 0000000000..332b3d9a8a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/seg0/cf0.dat differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/service.properties b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/service.properties new file mode 100644 index 0000000000..af9511d9c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/company-das/src/test/resources/dastest/service.properties @@ -0,0 +1,39 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#C:\apacheSVN\java\target\dastest +# ******************************************************************** +# *** Please do NOT edit this file. *** +# *** CHANGING THE CONTENT OF THIS FILE MAY CAUSE DATA CORRUPTION. *** +# ******************************************************************** +#Fri Feb 17 08:55:29 MST 2006 +SysschemasIndex2Identifier=225 +SyscolumnsIdentifier=144 +SysconglomeratesIndex1Identifier=49 +SysconglomeratesIdentifier=32 +SyscolumnsIndex2Identifier=177 +SysschemasIndex1Identifier=209 +SysconglomeratesIndex3Identifier=81 +SystablesIndex2Identifier=129 +SyscolumnsIndex1Identifier=161 +derby.serviceProtocol=org.apache.derby.database.Database +SysschemasIdentifier=192 +derby.storage.propertiesId=16 +SysconglomeratesIndex2Identifier=65 +derby.serviceLocale=en_US +SystablesIdentifier=96 +SystablesIndex1Identifier=113 diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/README b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/README new file mode 100644 index 0000000000..67c1aa32d5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/README @@ -0,0 +1,143 @@ +DataBinding Echo Sample +======================= + +This sample demonstrates how databindings are used to convert data formats as +the data flows between 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 ..\..\lib\tuscany-sca-manifest.jar;..\binding-echo-extension\target\sample-binding-echo-extension.jar;target\sample-databinding-echo.jar dbecho.EchoDataBindingClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:../binding-echo-extension/target/sample-binding-echo-extension.jar:target/sample-databinding-echo.jar dbecho.EchoDataBindingClient + + +Sample Overview +--------------- +If reference and service interfaces are the same in all but the formats of +data being passed to and returned from the operations of the interfaces, +then SCA will try to apply appropriate transformations to the data formats +to allow messages to pass. + +This sample shows this happening. ComponentA implements Interface1 which +defines; + + String call(String msg) + String call1(String msg) + +ComponentA defines a reference to ComponentB with Interface1. ComponentB +however implements Interface2 which defines; + + Node call(Node msg); + XMLStreamReader call1(XMLStreamReader msg); + +You can see from the test output below that SCA converts the call() msg from a +String to a DOM object (org.apache.xerces.dom.DeferredDocumentImpl). It +converts the call1() msg from a String to a XML stream reader +(com.ctc.wstx.sr.ValidatingStreamReader). + +databinding-echo/ + src/ + main/ + java/ + dbecho/ + ComponentAImpl.java - component implementation + ComponentBImpl.java - component implementation + Echo.java - service interface with data binding + EchoDataBindingClient.java - sample client code + Interface1.java - service interface with data binding + Interface2.java - service interface with data bindings + resources/ + META-INF/ + services/ + org.apache.tuscany.sca.core.ModuleActivator - specifies the module activation class to call + EchoDataBinding.composite - composite definition + wsdl/ + echo.wsdl - WSDL deinitions + test/ + java/ + dbecho/ + EchoDataBindingTestCase.java - junit test case + databinding-echo.png - pictorial representation of the sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +TODO - Needs more description of what else is going on in this test + properties, wsdl? + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows. + +cd databinding-echo +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] [Property] prefix: ABC + [java] [Property] prefix1: ABC + [java] [Property] bar: BAR + [java] ComponentA --> Received message: 123 [java.lang.String] + [java] ComponentB --> Received message: [#document: null] [org.apache.xerces.dom.DeferredDocumentImpl] + [java] ComponentB --> Returned message: [#document: null] [org.apache.xerces.dom.DeferredDocumentImpl] + [java] ComponentA --> Returned message: 123 [java.lang.String] + [java] [Property] prefix: ABC + [java] [Property] prefix1: ABC + [java] [Property] bar: BAR + [java] ComponentA --> Received message: 123 [java.lang.String] + [java] ComponentB --> Received message: com.ctc.wstx.sr.ValidatingStreamReader@4c444c44 [com.ctc.wstx.sr.ValidatingStreamReader] + [java] ComponentB --> Returned message: com.ctc.wstx.sr.ValidatingStreamReader@4c444c44 [com.ctc.wstx.sr.ValidatingStreamReader] + [java] ComponentA --> Returned message: 123 [java.lang.String] + [java] call response = 123 + [java] call1 response = 123 + + +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 databinding-echo +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running dbecho.EchoDataBindingTestCase +[Property] prefix: ABC +[Property] prefix1: ABC +[Property] bar: BAR +ComponentA --> Received message: 123 [java.lang.String] +ComponentB --> Received message: [#document: null] [org.apache.xerces.dom.DeferredDocumentImpl] +ComponentB --> Returned message: [#document: null] [org.apache.xerces.dom.DeferredDocumentImpl] +ComponentA --> Returned message: 123 [java.lang.String] +[Property] prefix: ABC +[Property] prefix1: ABC +[Property] bar: BAR +ComponentA --> Received message: 123 [java.lang.String] +ComponentB --> Received message: com.ctc.wstx.sr.ValidatingStreamReader@74e274e2 [com.ctc.wstx.sr.ValidatingStreamReader] +ComponentB --> Returned message: com.ctc.wstx.sr.ValidatingStreamReader@74e274e2 [com.ctc.wstx.sr.ValidatingStreamReader] +ComponentA --> Returned message: 123 [java.lang.String] +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.653 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/build.xml new file mode 100644 index 0000000000..22fc41228b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.png b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.png new file mode 100644 index 0000000000..afbbfff285 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.svg b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.svg new file mode 100644 index 0000000000..87964abf86 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/databinding-echo.svg @@ -0,0 +1,408 @@ + + + + + + + + + + image/svg+xml + + + + + + + + EchoDataBinding + ComponentB + + + + + + ComponentA + + + prefixprefix1bar Interface1 Interface2 EchoReferencebinding.echo + + + messagePrefix complexProperty + @DataBinding("org.w3c.dom.Node")&@DataBinding("javax.xml.stream.XMLStreamReader") @DataBinding("java.lang.String") + + <db:databinding name="org.apache.axiom.om.OMElement" /> + Interface1 + Echo @DataBinding("org.w3c.dom.Node") + @DataBinding("java.lang.String") + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/pom.xml new file mode 100644 index 0000000000..f90b1204a7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/pom.xml @@ -0,0 +1,76 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + + sample-databinding-echo + Apache Tuscany Echo Data Binding Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + sca-api + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-databinding + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + sample-binding-echo + 0.99-incubating-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java new file mode 100644 index 0000000000..5679614164 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentAImpl.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package dbecho; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +/** + * @version $Rev$ $Date$ + */ +public class ComponentAImpl implements Interface1 { + + private Interface1 componentBReference; + + @Constructor + public ComponentAImpl(@Reference(name = "componentBReference", required = true) + Interface1 componentBReference) { + this.componentBReference = componentBReference; + } + + public String call(String msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return (String) ret; + } + + public String call1(String msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentA --> Received message: " + request); + Object ret = componentBReference.call1(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentA --> Returned message: " + response); + return (String) ret; + } + + @Property(name="prefix") + public void setPrefix(String prefix) { + System.out.println("[Property] prefix: " + prefix); + } + + @Property(name="prefix1") + public void setPrefix1(String prefix1) { + System.out.println("[Property] prefix1: " + prefix1); + } + + /** + * @param bar the bar to set + */ + @Property(name="bar") + public void setBar(String bar) { + System.out.println("[Property] bar: " + bar); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java new file mode 100644 index 0000000000..ff8968837d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/ComponentBImpl.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package dbecho; + +import javax.xml.stream.XMLStreamReader; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@AllowsPassByReference +public class ComponentBImpl implements Interface2 { + + private Echo echoReference; + + @Constructor + public ComponentBImpl(@Reference(name = "echoReference", required = true) + Echo echoReference) { + this.echoReference = echoReference; + } + + public Node call(Node msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); + Node ret = (Node) echoReference.echo(msg); + String response = ret + " [" + ret.getClass().getName() + "]"; + System.out.println("ComponentB --> Returned message: " + response); + return ret; + } + + public XMLStreamReader call1(XMLStreamReader msg) { + String request = msg + " [" + msg.getClass().getName() + "]"; + System.out.println("ComponentB --> Received message: " + request); +// XMLStreamReader ret = (XMLStreamReader) echoReference.echo(msg); + String response = request; + System.out.println("ComponentB --> Returned message: " + response); + return msg; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Echo.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Echo.java new file mode 100644 index 0000000000..25ecc90454 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Echo.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package dbecho; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ + +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Echo { + Object echo(Object msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.java new file mode 100644 index 0000000000..9ec3819899 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/EchoDataBindingClient.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 dbecho; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + * @version $Rev$ $Date$ + */ +public class EchoDataBindingClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("EchoDataBinding.composite"); + + Interface1 componentA = scaDomain.getService(Interface1.class, "ComponentA"); + String response = componentA.call("123"); + String response1= componentA.call1("123"); + + + System.out.println("call response = " + response ); + System.out.println("call1 response = " + response1 ); + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface1.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface1.java new file mode 100644 index 0000000000..70b450e358 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface1.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package dbecho; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("java.lang.String") +@Remotable +public interface Interface1 { + String call(String msg); + String call1(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface2.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface2.java new file mode 100644 index 0000000000..b62f1f425d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/java/dbecho/Interface2.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 dbecho; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.databinding.annotation.DataBinding; +import org.osoa.sca.annotations.Remotable; +import org.w3c.dom.Node; + +/** + * @version $Rev$ $Date$ + */ +@DataBinding("org.w3c.dom.Node") +@Remotable +public interface Interface2 { + Node call(Node msg); + @DataBinding("javax.xml.stream.XMLStreamReader") + XMLStreamReader call1(XMLStreamReader msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/EchoDataBinding.composite b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/EchoDataBinding.composite new file mode 100644 index 0000000000..2f042b8e34 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/EchoDataBinding.composite @@ -0,0 +1,58 @@ + + + + + + + + ABC + + + + + + + + + + + + + + + + + ABC + + + BAR + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl new file mode 100644 index 0000000000..ef2308aa73 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/main/resources/wsdl/echo.wsdl @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.java new file mode 100644 index 0000000000..43434d8cee --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/databinding-echo/src/test/java/dbecho/EchoDataBindingTestCase.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 dbecho; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class EchoDataBindingTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoDataBinding.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + protected Interface1 componentA; + + public void testTransform() { + componentA = scaDomain.getService(Interface1.class, "ComponentA"); + componentA.call("123"); + componentA.call1("123"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/README b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/README new file mode 100644 index 0000000000..ed47d4cb22 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/README @@ -0,0 +1,79 @@ +Feed Aggregator Sample +====================================== +This sample demonstrates using the Feed binding to aggregator ATOM and RSS +and publish a new aggregated feed. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-feed-aggregator.jar feed.SampleServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-feed-aggregator.jar feed.SampleServer + +Now the server is started you can point your Web browser to the URL of the +aggregated feeds. + +Sample Overview +--------------- +The sample provides a single component exposing a Web resource. + +web-resource/ + src/ + main/ + java/ + feed/ + FeedAggregatorImpl.java - implementation of the Feed + aggregator component + SampleServer.java - starts the SCA Runtime and + publishes the aggregated feeds + resources/ + FeedAggregator.composite - the SCA assembly for this sample + feed-aggregator.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 using the +following commands + +cd feed-aggregator +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Added Servlet mapping: http://localhost:8083/rssAggregator + [java] Added Servlet mapping: http://localhost:8083/atomAggregator/* + [java] Sample Feed server started (press enter to shutdown) + + [java] To read the aggregated feeds, point your Web browser to the following addresses: + [java] http://localhost:8083/atomAggregator + [java] http://localhost:8083/atomAggregator/atomsvc (for the Atom service document) + [java] http://localhost:8083/rssAggregator + [java] http://localhost:8083/atomAggregator?feedType=rss_2.0 + [java] http://localhost:8083/rssAggregator?feedType=atom_1.0 + +As this point the aggregated Feeds are exposed by a web server started +automatically by the SCA runtime. To stop the server just press enter. + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built using +Maven as follows. + +cd feed-aggregator +mvn + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/build.xml new file mode 100644 index 0000000000..2118e13db7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/pom.xml new file mode 100644 index 0000000000..eadcd22691 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../pom.xml + + sample-feed-aggregator + Apache Tuscany Atom+RSS Feed Aggregator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-feed + 0.99-incubating-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-http-tomcat + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java new file mode 100644 index 0000000000..6d15b5426b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/AggregatorImpl.java @@ -0,0 +1,100 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package feed; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sca.binding.feed.collection.NotFoundException; +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import com.sun.syndication.feed.atom.Content; +import com.sun.syndication.feed.atom.Entry; +import com.sun.syndication.feed.atom.Link; +import com.sun.syndication.feed.atom.Person; + +/** + * Implementation of an SCA component that aggregates several + * Atom and RSS feeds. + * + * @version $Rev$ $Date$ + */ +public class AggregatorImpl implements org.apache.tuscany.sca.binding.feed.collection.Collection { + + @Reference + public org.apache.tuscany.sca.binding.feed.collection.Collection feed1; + @Reference + public org.apache.tuscany.sca.binding.feed.collection.Collection feed2; + @Reference(required = false) + public Sort sort; + + @Property + public String feedTitle = "Aggregated Feed"; + @Property + public String feedDescription = "Anonymous Aggregated Feed"; + @Property + public String feedAuthor = "anonymous"; + + @SuppressWarnings("unchecked") + public com.sun.syndication.feed.atom.Feed getFeed() { + + // Create a new Feed + com.sun.syndication.feed.atom.Feed feed = new com.sun.syndication.feed.atom.Feed(); + feed.setTitle(feedTitle); + Content subtitle = new Content(); + subtitle.setValue(feedDescription); + feed.setSubtitle(subtitle); + Person author = new Person(); + author.setName(feedAuthor); + feed.setAuthors(Collections.singletonList(author)); + Link link = new Link(); + link.setHref("http://incubator.apache.org/tuscany"); + feed.getAlternateLinks().add(link); + + // Aggregate entries from feed1 and feed2 + List entries = new ArrayList(); + entries.addAll(feed1.getFeed().getEntries()); + entries.addAll(feed2.getFeed().getEntries()); + + // Sort entries by published date + if (sort != null) + feed.setEntries(sort.sort(entries)); + else + feed.setEntries(entries); + return feed; + } + + public void delete(String id) throws NotFoundException { + } + + public Entry get(String id) throws NotFoundException { + return null; + } + + public Entry post(Entry entry) { + return null; + } + + public Entry put(String id, Entry entry) throws NotFoundException { + return null; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SampleServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SampleServer.java new file mode 100644 index 0000000000..05961a315c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SampleServer.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 feed; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class SampleServer { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("FeedAggregator.composite"); + + try { + System.out.println("Sample Feed server started (press enter to shutdown)"); + System.out.println(); + System.out.println("To read the aggregated feeds, point your Web browser to the following addresses:"); + System.out.println("http://localhost:8083/atomAggregator"); + System.out.println("http://localhost:8083/atomAggregator/atomsvc (for the Atom service document)"); + System.out.println("http://localhost:8083/rssAggregator"); + System.out.println("http://localhost:8083/atomAggregator?feedType=rss_2.0"); + System.out.println("http://localhost:8083/rssAggregator?feedType=atom_1.0"); + System.out.println(); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + // RssFeed feedService = scaDomain.getService(RssFeed.class, + // "RssAggregatorComponent"); + // SyndFeed syndFeed = feedService.get(); + // SyndFeedOutput output = new SyndFeedOutput(); + // output.output(syndFeed,new PrintWriter(System.out)); + + scaDomain.close(); + System.out.println("Sample Feed server stopped"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/Sort.java b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/Sort.java new file mode 100644 index 0000000000..db26ad9350 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/Sort.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 feed; + +import java.util.List; + +import com.sun.syndication.feed.atom.Entry; + +/** + * The Sort service business interface. + * + * @version $Rev$ $Date$ + */ +public interface Sort { + + /** + * Sort feed entries by published date. + * @param entries + * @return + */ + List sort(List entries); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SortImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SortImpl.java new file mode 100644 index 0000000000..62d90bfa3b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/java/feed/SortImpl.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package feed; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.osoa.sca.annotations.Property; + +import com.sun.syndication.feed.atom.Entry; + +/** + * Implementation of a Feed Sort service component. + * + * @version $Rev$ $Date$ + */ +public class SortImpl implements Sort { + + @Property + public boolean newFirst = true; + + @SuppressWarnings("unchecked") + public List sort(List entries) { + Entry[] entriesArray = new Entry[entries.size()]; + entriesArray = (Entry[])entries.toArray(entriesArray); + Arrays.sort(entriesArray, new Comparator() { + public int compare(final Object xObj, final Object yObj) { + Date xDate = ((Entry)xObj).getPublished(); + Date yDate = ((Entry)yObj).getPublished(); + if (xDate == null) + return -1; + if (newFirst) + return yDate.compareTo(xDate); + else + return xDate.compareTo(yDate); + } + }); + return Arrays.asList(entriesArray); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/resources/FeedAggregator.composite b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/resources/FeedAggregator.composite new file mode 100644 index 0000000000..df02ba8536 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/feed-aggregator/src/main/resources/FeedAggregator.composite @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + Rss Sample + + + + true + + + + + + + + + + + + Atom Sample + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/README b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/README new file mode 100644 index 0000000000..cc25b50192 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/README @@ -0,0 +1,101 @@ +Hello World Dojo RPC Sample +=========================== +This sample demostrates the SCA JSONRPC binding using a simple web app that +uses the RPC support of the Dojo Toolkit to an SCA service. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-helloworld-dojo.war) +to you web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-dojo + +The port and hostname will of course vary depending on your local installation. + +See also the similar helloworld-jsonrpc sample which also uses the SCA JSONRPC binding +but uses SCA scaDomain.js script on the client instead of the Dojo Toolkit. + +Sample Overview +--------------- +The sample provides a single service with an operation that reflects +a greeting back to the caller. The service is exposed using the JSONRPC +binding. The web app provided shows how the Dojo Toolkit JSON-RPC support can be +used to invoke the SCA service. + +The web app provided shows how the service can be called by using the DOJO toolkit. + +helloworld-dojo/ + build-dojo.xml - This file is an Ant script used by the + sample build process to download the Dojo Toolkit + and get it included in the WAR file + for use by the sample. + src/ + main/ + java/ + helloworldjsonrpc/ + HelloWorldService.java - service interface + HelloWorldServiceImpl.java - service implementation + resources/ + jsonrpc.composite - the SCA assembly for this sample + webapp + dojo/ - the Dojo toolkit (this directory is created only + when you build the samples from the source distribution) + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + HelloWorldJSONRPC.html - the web application that calls the + SCA service via JSONRPC + style.css - style sheet + + helloworld-jsonrpc.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file that unpacks the + dojo installation + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd helloworld-dojo +ant package + +This should result in a war file (sample-helloworld-dojo.war) in the target +directory. Copy this war file to your web app deployment directory in your +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-dojo + +The port and hostname will of course vary depending on your local installation. + +You should see a web page that allows you to send messages, via JSONRPC, to the +application running in the Tuscany SCA Runtime + +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 helloworld-dojo +mvn + +Again this should result in a war file (sample-helloworld-dojo.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build-dojo.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build-dojo.xml new file mode 100644 index 0000000000..335a10817a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build-dojo.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build.xml new file mode 100644 index 0000000000..261d55c540 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/build.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.png b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.svg b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..5c5cb91157 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/helloworld-jsonrpc.svg @@ -0,0 +1,177 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldjsonrpc + + HelloWorldJSONServiceComponent + HelloWorldService + WebApp + DOJO + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/pom.xml new file mode 100644 index 0000000000..16f33de216 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/pom.xml @@ -0,0 +1,134 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-helloworld-dojo + war + Apache Tuscany Dojo Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.apache.maven.plugins + maven-antrun-plugin + + + + + ant + ant-trax + 1.6.5 + + + + + + install-dojo + validate + + run + + + + + + + + + + + copy-dojo-files + generate-resources + + run + + + + + + + + + + + + clean-dojo-files + clean + + run + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworldjsonrpc; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface HelloWorldService { + + String getGreetings(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..35fd00fabd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.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 helloworldjsonrpc; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service component. + */ +@Service(HelloWorldService.class) +public class HelloWorldServiceImpl implements HelloWorldService { + + /* + * @see org.apache.tuscany.samples.helloworld.HelloWorldServiceComponent#getGreetings() + */ + public String getGreetings(String name) { + return "jsonrpcHello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/resources/jsonrpc.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..e8aa2b6615 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/HelloWorldJSONRPC.html @@ -0,0 +1,91 @@ + + + + Tuscany JSON-RPC HelloWorld Example + + + + + + + + + + + + + +

Tuscany Dojo JSON-RPC HelloWorld Sample

+ + + + + + + + + + + + + + + + + + +
Dojo Example
+

This example uses the Dojo Toolkit + to create a JavaScript object helloWorldService for the SCA service + 'HelloWorldService' using Dojo's RPC classes + and providing them with SCA/SCADomain/HelloWorldService?smd + for Simple Method Description (SMD) input.

+

It then creates a Dojo button that will envoke the getGreetings method of the HelloWorldService object.

+
RequestResponse
+
helloWorldService.getGreetings("Dojo").addCallback(contentCallBack);

+
+
None Yet.
+
+
Dojo Debug:
+
+ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..2c178c1ddc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..52117b1dce --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,45 @@ + + + + + + + Tuscany sample HelloWorld JSON-RPC + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + TuscanyServlet + org.apache.tuscany.sca.host.webapp.TuscanyServlet + + + + TuscanyServlet + /SCA/* + + + + HelloWorldJSONRPC.html + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/style.css b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-dojo/src/main/webapp/style.css @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +* { font-family: arial; } + +table, th, td { border: 2px solid blue; border-collapse: collapse; } +th { color: white; background-color: blue; } diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/README b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/README new file mode 100644 index 0000000000..93a2c703ac --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/README @@ -0,0 +1,90 @@ +Hello World JSONRPC Sample +========================== +This sample demostrates the JSONRPC binding using a simple web app that +talks JSONRPC to an SCA service. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +As this sample provides a web app there is a manual step where the WAR file +that contains the sample is copied to your web app container. If you just want +to give this sample a go deploy the WAR file (target/sample-helloworld-jsonrpc.war) +to you web application server. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-jsonrpc + +The port and hostname will of course vary depending on your local installation. + +Sample Overview +--------------- +The sample provides a single service with an operation that reflects +a greeting back to the caller. The service is exposed using the JSONRPC +binding. The web app provided shows how the SCA-provided JSON client can be +used to invoke the SCA service. + +helloworld-jsonrpc/ + src/ + main/ + java/ + helloworldjsonrpc/ + HelloWorldService.java - service interface + HelloWorldServiceImpl.java - service implementation + resources/ + jsonrpc.composite - the SCA assembly for this sample + webapp + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + WEB-INF/ + web.xml - defines the listener that starts up the + Tuscany SCA runtime + HelloWorldJSONRPC.html - the web application that calls the + SCA service via JSONRPC + style.css - style sheet + + helloworld-jsonrpc.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file that unpacks the + dojo installation + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd helloworld-jsonrpc +ant package + +This should result in a war file (sample-helloworld-jsonrpc.war) in the target +directory. Copy this war file to your web app deployment directory in your +web app container. + +The process for getting the web app running will depend on which web app container +you are using. For example, if you are using Tomcat then it is simply a matter +of copying the WAR file to the webapps directory. + +Once the web app is deployed use your browser to visit the following URL; + +http://localhost:8080/sample-helloworld-jsonrpc + +The port and hostname will of course vary depending on your local installation. + +You should see a web page that allows you to send messages, via JSONRPC, to the +application running in the Tuscany SCA Runtime + +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 helloworld-jsonrpc +mvn + +Again this should result in a war file (sample-helloworld-jsonrpc.war) in the target +directory. Follow the steps described in the previous section for running the web +app and for the expected results. + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/build.xml new file mode 100644 index 0000000000..dd3d5e6512 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/build.xml @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.png b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.png new file mode 100644 index 0000000000..57f90aed01 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg new file mode 100644 index 0000000000..fe966d8c17 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/helloworld-jsonrpc.svg @@ -0,0 +1,177 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldjsonrpc + + HelloWorldJSONServiceComponent + HelloWorldService + WebApp + DOJO + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/pom.xml new file mode 100644 index 0000000000..e7c0f37e99 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/pom.xml @@ -0,0 +1,73 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-helloworld-jsonrpc + war + Apache Tuscany JSON-RPC Sample WebApp + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-webapp + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-jsonrpc + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java new file mode 100644 index 0000000000..3d8ea24f04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworldjsonrpc; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface HelloWorldService { + + String getGreetings(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.java new file mode 100644 index 0000000000..35fd00fabd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/java/helloworldjsonrpc/HelloWorldServiceImpl.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 helloworldjsonrpc; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service component. + */ +@Service(HelloWorldService.class) +public class HelloWorldServiceImpl implements HelloWorldService { + + /* + * @see org.apache.tuscany.samples.helloworld.HelloWorldServiceComponent#getGreetings() + */ + public String getGreetings(String name) { + return "jsonrpcHello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite new file mode 100644 index 0000000000..e895ab455d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/resources/jsonrpc.composite @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html new file mode 100644 index 0000000000..98853189db --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/HelloWorldJSONRPC.html @@ -0,0 +1,75 @@ + + + + Tuscany JSON-RPC HelloWorld Example + + + + + + + + + + +

Tuscany JSON-RPC HelloWorld Sample

+ + + + + + + + + + + + + + + +
Non-Dojo Example
+ This example uses the JavaScript served from + SCA/SCADomain/scaDomain.js + to make JSON-RPC requests to the SCA service 'HelloWorldService' +
RequestResponse
+

+ Name please:     + + +

+ +
+
None Yet.
+
+ + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..c8246e15a7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/META-INF/sca-contribution.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..52117b1dce --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,45 @@ + + + + + + + Tuscany sample HelloWorld JSON-RPC + + + org.apache.tuscany.sca.host.webapp.TuscanyContextListener + + + + TuscanyServlet + org.apache.tuscany.sca.host.webapp.TuscanyServlet + + + + TuscanyServlet + /SCA/* + + + + HelloWorldJSONRPC.html + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/style.css b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/style.css new file mode 100644 index 0000000000..1071583264 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-jsonrpc/src/main/webapp/style.css @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +* { font-family: arial; } + +table, th, td { border: 2px solid blue; border-collapse: collapse; } +th { color: white; background-color: blue; } diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/README b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/README new file mode 100644 index 0000000000..8ee8dd7ff5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/README @@ -0,0 +1,153 @@ +Hello World Web Service References Sample +========================================= +This sample demonstrates an SCA reference that uses a web service binding. + +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 you need to run the server first +so open a command prompt, navigate to the helloworld-ws-service 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-helloworld-ws-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer + + +Once the server is running 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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-reference.jar helloworld.HelloWorldClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-reference.jar helloworld.HelloWorldClient + + +Sample Overview +--------------- +The sample provides a single component that is wired to a reference with a +web service binding. The binding refers to WSDL that identifies the service +exposed by the helloworld-ws-service sample. + +helloworld-ws-reference/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldClient.java - starts the SCA Runtime and + deploys the helloworldwsclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + wsdl + helloworld.wsdl - the service description that the + SCA reference uses to bind to + helloworldwsclient.composite - the SCA assembly for this sample + logging.properties - log4j configuration file + test/ + java/ + helloworld/ + HelloWorldClientTestCase.java - JUnit test case + HelloWorldServerTest.java - starts the Web service + helloworld-ws-reference.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. Before +you do this start up the service that the reference will talk to. To do this +run up the helloworld-ws-service test. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-ws-service +ant run + +Once done you can now compile and run this sample using the following commands; + +cd helloworld-ws-reference +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello World + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven you don't need to run the helloworld- +ws-service sample first as Maven does this for you. + +cd helloworld-ws-reference +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldClientTestCase +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +10-May-2007 13:40:34 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +10-May-2007 13:40:35 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_1_4.xsd +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/xml.xsd +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/web-app_2_4.xsd +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +10-May-2007 13:40:35 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_client +_1_1.xsd +10-May-2007 13:40:35 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +10-May-2007 13:40:35 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +Injected helloWorldService +Called getGreetings +10-May-2007 13:40:36 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.349 sec + +Results : + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/build.xml new file mode 100644 index 0000000000..71ee66b31e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.png b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.png new file mode 100644 index 0000000000..bd2bba41db Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.svg b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.svg new file mode 100644 index 0000000000..354ffbae8f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/helloworld-ws-reference.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldwsclient + + HelloWorldServiceComponent + + + HelloWorldService + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/pom.xml new file mode 100644 index 0000000000..e2729e1815 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-reference + Apache Tuscany HelloWorld Web Service Client Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + sample-helloworld-ws-service + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..4559b282fe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate the HelloWorld service and invoke it. + */ +public class HelloWorldClient { + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + + String value = helloWorldService.getGreetings("World"); + System.out.println(value); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..433a98fd7f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +/** + * The interface for the helloworld service + */ +@Remotable +@Service +public interface HelloWorldService { + public String getGreetings(String name); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..0dee19550b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/java/helloworld/HelloWorldServiceComponent.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +/** + * The HelloWorld service implementation + */ +public class HelloWorldServiceComponent implements HelloWorldService { + + HelloWorldService helloWorldService; + + public String getGreetings(String name) { + System.out.println("Called getGreetings"); + return helloWorldService.getGreetings(name); + } + + public HelloWorldService getHelloWorldService() { + System.out.println("Got Injected helloWorldService"); + return helloWorldService; + } + + public void setHelloWorldService(HelloWorldService helloWorldService) { + System.out.println("Injected helloWorldService"); + this.helloWorldService = helloWorldService; + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..899ad5ce35 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/logging.properties @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# $Rev$ $Date$ +# + +# Custom logging configuration for Tuscany samples +# By default, only INFO level logging is enabled and ALL messages get sent to the console +# For more messages from the runtime, uncomment specific settings at the end of this file +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +.level=INFO + +# Uncomment the next setting to get all Tuscany messages (this will be a lot) +#org.apache.tuscany.level=FINEST diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..1e468bc9ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..7ce89179c2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldClientTestCase.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Test case for helloworld web service client + */ +public class HelloWorldClientTestCase { + + private HelloWorldService helloWorldService; + private HelloWorldService helloTuscanyService; + private SCADomain scaDomain; + + private SCATestCaseRunner server; + + @Before + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + helloTuscanyService = scaDomain.getService(HelloWorldService.class, "HelloTuscanyServiceComponent"); + + server = new SCATestCaseRunner(HelloWorldTestServer.class); + server.before(); + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testWSClient() throws Exception { + String msg = helloWorldService.getGreetings("Smith"); + Assert.assertEquals("Hello Smith", msg); + } + + @Test + public void testEmbeddedReferenceClient() throws Exception { + String msg = helloTuscanyService.getGreetings("Tuscany"); + Assert.assertEquals("Hello Tuscany", msg); + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..4b0c40dafd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-reference/src/test/java/helloworld/HelloWorldTestServer.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 helloworld; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Starts up the SCA runtime which starts listening for service requests + */ +public class HelloWorldTestServer { + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + try { + scaDomain = SCADomain.newInstance("helloworldws.composite"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/README b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/README new file mode 100644 index 0000000000..3689f79149 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/README @@ -0,0 +1,210 @@ +Hello World Web Service References Sample +========================================= +This sample demonstrates an SCA reference that uses a web service binding which works with SDO. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens, you need to run the server first +so open a command prompt, navigate to the helloworld-ws-service sample directory +and do + +ant run-server + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld-ws-sdo.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworld-ws-sdo.HelloWorldServer + +You should see the following output: + +Buildfile: build.xml + +run-server: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Aug 24, 2007 11:17:33 AM org.apache.catalina.core.StandardEngine sta +rt + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.ContextConfig d +efaultWebConfig + [java] INFO: No default web.xml + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0. +xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_1.dtd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_2.dtd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_0.xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.catalina.startup.DigesterFactory + register + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser +vices_1_1.xsd + [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol ini +t + [java] INFO: Initializing Coyote HTTP/1.1 on http-8085 + [java] Aug 24, 2007 11:17:34 AM org.apache.coyote.http11.Http11Protocol sta +rt + [java] INFO: Starting Coyote HTTP/1.1 on http-8085 + [java] Aug 24, 2007 11:17:34 AM org.apache.tuscany.sca.http.tomcat.TomcatSe +rver addServletMapping + [java] INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService + + [java] HelloWorld server started (press enter to shutdown) + +The server is now ready. + +Then open another command window to run the client: + +ant run + +OR if you don't have ant, on Windows do + +java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-sdo.jar helloworld-ws-sdo.HelloWorldClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-sdo.jar helloworld-ws-sdo.HelloWorldClient + +You should be able to see the following result: + +Buildfile: build.xml + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello David Haney + +BUILD SUCCESSFUL +Total time: 9 seconds + + +Sample Overview +--------------- +The sample provides a single component that is wired to a reference with a +web service binding. The binding refers to WSDL that identifies the service +exposed by the helloworld-ws-service sample. + +helloworld-ws-sdo/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldServiceComponent.java - component implementation + HelloWorldClient.java - starts the SCA Runtime and + deploys the helloworldwsclient + .composite. It then calls the + HelloWorldServiceComponent + resources/ + wsdl + helloworld.wsdl - the service description that the + SCA reference uses to bind to service. + + test/ + java/ + helloworld/ + HelloWorldClientTestCase.java - JUnit test case + helloworld-ws-sdo.png - a pictorial representation of the + sample .composite file + build.xml - the Ant build file + pom.xml - the Maven build file + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant. Before +you do this start up the service that the reference will talk to. To do this +run up the helloworld-ws-service test. Take a look at the README in that sample +and you will see you need the following commands + +cd helloworld-ws-sdo +ant + + +You should see the following output from the run target. + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Injected helloWorldService + [java] Called getGreetings + [java] Hello World + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When using Maven you don't need to run the helloworld- +ws-service sample first as Maven does this for you. + +cd helloworld-ws-sdo +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldClientTestCase +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +Aug 23, 2007 2:27:32 PM org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.ContextConfig defaultWebConf +ig +INFO: No default web.xml +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +Aug 23, 2007 2:27:32 PM org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +Aug 23, 2007 2:27:32 PM org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +Aug 23, 2007 2:27:32 PM org.apache.tuscany.sca.http.tomcat.TomcatServer addServl +etMapping +INFO: Added Servlet mapping: http://localhost:8085/HelloWorldService +Injected helloWorldService +Called getGreetings +Aug 23, 2007 2:27:34 PM org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 8.502 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/build.xml new file mode 100644 index 0000000000..401315d424 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/build.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.png b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.png new file mode 100644 index 0000000000..bd2bba41db Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg new file mode 100644 index 0000000000..333ad53e0a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/helloworld-ws-sdo.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldwsclient + + HelloWorldServiceComponent + + + HelloWorldService + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/pom.xml new file mode 100644 index 0000000000..bd0d513a86 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/pom.xml @@ -0,0 +1,139 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-sdo + Apache Tuscany HelloWorld Web Service SDO Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.0-incubating + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 0.99-incubating-SNAPSHOT + compile + + + + org.apache.tuscany.sca + tuscany-http-tomcat + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-test-source + + + + target/sdo-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.0-incubating + + + generate-helloworld-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/helloworld.wsdl + helloworld + Helloworld + true + true + true + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java new file mode 100644 index 0000000000..de4795ceaf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldClient.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, locate the + * HelloWorld service and invoke it. + */ +public class HelloWorldClient { + + public final static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + HelloWorldService helloWorldService = + scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + + Name name = HelloworldFactory.INSTANCE.createName(); + + name.setFirst("David"); + name.setLast("Haney"); + + String value = helloWorldService.getGreetings(name); + System.out.println(value); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..c950f7df04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldImpl implements HelloWorldService { + + public String getGreetings(Name name) { + return "Hello " + name.getFirst() + " " + name.getLast(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..e03ed4dc25 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServer.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This server program shows how to create an SCA runtime, and start it which + * activates the helloworld Web service endpoint. + */ +public class HelloWorldServer { + + public static void main(String[] args) { + + SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite"); + + try { + System.out.println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("HelloWorld server stopped"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..e9e39aa1dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +/** + * The interface for the helloworld service + */ +@Remotable +@Service +public interface HelloWorldService { + public String getGreetings(Name name); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java new file mode 100644 index 0000000000..711eef63b5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/java/helloworld/HelloWorldServiceComponent.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +/** + * The HelloWorld service implementation + */ +public class HelloWorldServiceComponent implements HelloWorldService { + + HelloWorldService helloWorldService; + + public String getGreetings(Name name) { + System.out.println("Called getGreetings"); + return helloWorldService.getGreetings(name); + } + + public HelloWorldService getHelloWorldService() { + System.out.println("Got Injected helloWorldService"); + return helloWorldService; + } + + public void setHelloWorldService(HelloWorldService helloWorldService) { + System.out.println("Injected helloWorldService"); + this.helloWorldService = helloWorldService; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..e8f45d2901 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldws.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite new file mode 100644 index 0000000000..34db47e04d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/helloworldwsclient.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/logging.properties b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/logging.properties new file mode 100644 index 0000000000..3dca310cdb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/logging.properties @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +# $Rev$ $Date$ +# + +# Custom logging configuration for Tuscany samples +# By default, only INFO level logging is enabled and ALL messages get sent to the console +# For more messages from the runtime, uncomment specific settings at the end of this file +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = ALL +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +.level=INFO + +# Uncomment the next setting to get all Tuscany messages (this will be a lot) +#org.apache.tuscany.level=FINEST diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..2ecc0bea43 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.java new file mode 100644 index 0000000000..11564c370f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldClientTestCase.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 helloworld; + +import junit.framework.Assert; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Test case for helloworld web service client + */ +public class HelloWorldClientTestCase { + + private HelloWorldService helloWorldService; + private SCADomain scaDomain; + + private SCATestCaseRunner server; + + @Before + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("helloworldwsclient.composite"); + helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent"); + + server = new SCATestCaseRunner(HelloWorldTestServer.class); + server.before(); + + } catch (Throwable e) { + e.printStackTrace(); + } + } + + @Test + public void testWSClient() throws Exception { + Name name = HelloworldFactory.INSTANCE.createName(); + name.setFirst("John"); + name.setLast("Smith"); + String msg = helloWorldService.getGreetings(name); + Assert.assertEquals("Hello John Smith", msg); + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.java new file mode 100644 index 0000000000..4b0c40dafd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-sdo/src/test/java/helloworld/HelloWorldTestServer.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 helloworld; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Starts up the SCA runtime which starts listening for service requests + */ +public class HelloWorldTestServer { + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + try { + scaDomain = SCADomain.newInstance("helloworldws.composite"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/README b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/README new file mode 100644 index 0000000000..b82d5bd329 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/README @@ -0,0 +1,132 @@ +Hello World Web Service Service Sample +====================================== +This sample demonstrates an SCA service that uses a web service binding. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-helloworld-ws-service.jar helloworld.HelloWorldServer + +Now the server is started you can use the helloworld-ws-reference sample to +exercise it. + +Sample Overview +--------------- +The sample provides a single component that is wired to a service with a +web service binding. + +helloworld-ws-service/ + src/ + main/ + java/ + helloworld/ + HelloWorldService.java - interface description for + HelloWorldServiceComponent + HelloWorldImpl.java - component implementation + HelloWorldServer.java - starts the SCA Runtime and + deploys the helloworldws + .composite and then waits for the + service to be called via web services + resources/ + wsdl/ + helloworld.wsdl - the service description that describes + the exposed service + helloworldws.composite - the SCA assembly for this sample + test/ + java/ + helloworld/ + HelloWorldServerTestCase.java - JUnit test case + helloworld-ws-service.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 using the +following commands + +cd helloworld-ws-service +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom. +om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] HelloWorld server started (press enter to shutdown) + +As this point the SCA service is exposed as a web service by a web server +started automatically by the SCA runtime. To stop the server just press +enter. + +To exercise the service run up the helloworld-ws-reference sample. Take a look at +the README in that sample and you will see you need the following commands + +cd helloworld-ws-reference +ant run + +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 you don't need to run the helloworld- +ws-reference sample as Maven includes a simple ping test to make sure that the +service is available + +cd helloworld-ws-service +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldServerTestCase +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAX +Utils). +log4j:WARN Please initialize the log4j system properly. +10-May-2007 13:48:42 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +10-May-2007 13:48:42 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +10-May-2007 13:48:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +10-May-2007 13:48:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +1.dtd +10-May-2007 13:48:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_ +2.dtd +10-May-2007 13:48:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_ +0.xsd +10-May-2007 13:48:42 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xs +d +10-May-2007 13:48:43 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8085 +10-May-2007 13:48:43 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8085 +10-May-2007 13:48:43 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8085 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.857 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/build.xml new file mode 100644 index 0000000000..46678febc3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.png b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.png new file mode 100644 index 0000000000..6f7d9dd450 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.svg b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.svg new file mode 100644 index 0000000000..3305faeed8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/helloworld-ws-service.svg @@ -0,0 +1,149 @@ + + + + + + + + + + image/svg+xml + + + + + + + + helloworldws + + HelloWorldServiceComponent + + HelloWorldWebService + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/pom.xml new file mode 100644 index 0000000000..501d212aeb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-helloworld-ws-service + Apache Tuscany HelloWorld Web Service Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-http-tomcat + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0de3c70303 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Service; + +/** + * This class implements the HelloWorld service. + */ +@Service(HelloWorldService.class) +public class HelloWorldImpl implements HelloWorldService { + + public String getGreetings(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java new file mode 100644 index 0000000000..e03ed4dc25 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldServer.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This server program shows how to create an SCA runtime, and start it which + * activates the helloworld Web service endpoint. + */ +public class HelloWorldServer { + + public static void main(String[] args) { + + SCADomain scaDomain = SCADomain.newInstance("helloworldws.composite"); + + try { + System.out.println("HelloWorld server started (press enter to shutdown)"); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("HelloWorld server stopped"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java new file mode 100644 index 0000000000..bd527ff8e2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/java/helloworld/HelloWorldService.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +/** + * This is the business interface of the HelloWorld greetings service. + */ +@Remotable +@Service +public interface HelloWorldService { + + public String getGreetings(String name); +} + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/helloworldws.composite b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/helloworldws.composite new file mode 100644 index 0000000000..76ccf71fb8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/helloworldws.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl new file mode 100644 index 0000000000..454763410c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/main/resources/wsdl/helloworld.wsdl @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.java new file mode 100644 index 0000000000..99c1f4d799 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/helloworld-ws-service/src/test/java/helloworld/HelloWorldServerTestCase.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 helloworld; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests that the helloworld server is available + */ +public class HelloWorldServerTestCase{ + + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + scaDomain = SCADomain.newInstance("helloworldws.composite"); + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @Test + public void testServiceCall() throws IOException { + HelloWorldService helloWorldService = scaDomain.getService(HelloWorldService.class, "HelloWorldServiceComponent/HelloWorldService"); + assertNotNull(helloWorldService); + + assertEquals("Hello Smith", helloWorldService.getGreetings("Smith")); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/README b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/README new file mode 100644 index 0000000000..27de00e8ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/README @@ -0,0 +1,116 @@ +Composite Implementation Sample +=============================== + +This sample shows how composites can be used to implement 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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-implementation-composite.jar composite.CompositeClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-implementation-composite.jar composite.CompositeClient + + +Sample Overview +--------------- + +The sample is comprised of three composites. Take a look at the composite file +or the .svg/.png file which shows the composite file in pictorial form. The +OuterComposite defines three components two of which are implemented using +composites. The SourceComponent calls each TargetComponent in turn. There is a +callback which returns from each TargetComponent to the SourceComponent. + +implementation-composite/ + src/ + main/ + java/ + composite/ + Source.java - interface for the source component + SourceImpl.java - implementation for the source component + SourceCallback.java - source component callback interface + Target.java - interface for the target component + TargetImpl.java - implementation for the target component + CompositeClient.java - starts the SCA Runtime and + deploys the OuterComposite.composite. + This in turn pulls in the two inner + composites + resources/ + META-INF/ + sca-contribution.xml - specifies the composite to be deployed + OuterComposite.composite - the top level SCA assembly for this sample + InnerComposite.composite - included by OuterComposite.composite + InnerComposite2.composite - included by OuterComposite.composite + test/ + java/ + composite/ + CompositeTestCase.java - JUnit test case + implementation-composite.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 implementation-composite +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Main thread Thread[main,5,main] + [java] Source: Client.main -> Source.clientMethod + [java] Source: Client.main => Source.clientMethod2 + [java] Sleeping ... + [java] Target: Client.main -> Source.clientMethod + [java] Work thread Thread[pool-1-thread-1,5,main] + [java] Result: Client.main -> Source.clientMethod -> Target.someMethod + [java] Target: Client.main => Source.clientMethod2 + [java] Work thread Thread[pool-1-thread-2,5,main] + [java] Result: Client.main => Source.clientMethod2 -> Target.someMethod + + +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 implementation-composite +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running composite.CompositeTestCase +Main thread Thread[main,5,main] +Source: Client.main -> Source.clientMethod +Source: Client.main => Source.clientMethod2 +Sleeping ... +Target: Client.main => Source.clientMethod2 +Work thread Thread[pool-1-thread-2,5,main] +Result: Client.main => Source.clientMethod2 -> Target.someMethod +Target: Client.main -> Source.clientMethod +Work thread Thread[pool-1-thread-1,5,main] +Result: Client.main -> Source.clientMethod -> Target.someMethod +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.973 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/build.xml new file mode 100644 index 0000000000..7aa31aab8b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.png b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.png new file mode 100644 index 0000000000..4c6d71bc03 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.svg b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.svg new file mode 100644 index 0000000000..0e60354aab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/implementation-composite.svg @@ -0,0 +1,658 @@ + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + OuterComposite + InnerComposite + + OuterComposite.composite + InnerComposite.composite + InnerComposite2.composite + SourceComponent + + TargetComponentRef TargetComponentRef2 + + TargetComponent + + TargetComponent2 + + + InnerSourceService + InnerSourceComponent + + + + + + TargetComponentRef TargetComponentRef2 + + promote promote + InnerTargetService + InnerTargetComponent + + TargetImpl Target + + Target + + SourceImpl + Source + SourceCallback + + + + + Target Source + InnerComposite2 promote promote + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/pom.xml new file mode 100644 index 0000000000..8b041e3ed2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/pom.xml @@ -0,0 +1,66 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-composite + Apache Tuscany Composite Implementation Sample + A sample showing local wiring of a component implemented by a nested composite + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/CompositeClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/CompositeClient.java new file mode 100644 index 0000000000..bf743e1797 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/CompositeClient.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 composite; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Simple client program that invokes the components that we wired together. + */ +public class CompositeClient { + + public static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance(); + + Source source = scaDomain.getService(Source.class, "SourceComponent"); + + System.out.println("Main thread " + Thread.currentThread()); + source.clientMethod("Client.main"); + System.out.println("Sleeping ..."); + Thread.sleep(1000); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Source.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Source.java new file mode 100644 index 0000000000..d0efcc1df1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Source.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package composite; + +public interface Source { + + void clientMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceCallback.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceCallback.java new file mode 100644 index 0000000000..baa95a8e39 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceCallback.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package composite; + +public interface SourceCallback { + + void receiveResult(String result); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceImpl.java new file mode 100644 index 0000000000..b9a0c7ff74 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/SourceImpl.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 composite; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +@Service(Source.class) +@Scope("COMPOSITE") +public class SourceImpl implements Source, SourceCallback { + + private Target targetReference; + private Target targetReference2; + + @Reference + public void setTargetReference(Target target) { + this.targetReference = target; + } + + @Reference + public void setTargetReference2(Target target) { + this.targetReference2 = target; + } + + public void clientMethod(String arg) { + System.out.println("Source: " + arg + " -> Source.clientMethod"); + targetReference.someMethod(arg + " -> Source.clientMethod"); + + System.out.println("Source: " + arg + " => Source.clientMethod2"); + targetReference2.someMethod(arg + " => Source.clientMethod2"); + } + + public void receiveResult(String result) { + System.out.println("Work thread " + Thread.currentThread()); + System.out.println("Result: " + result); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Target.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Target.java new file mode 100644 index 0000000000..9a8f68a7fa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/Target.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 composite; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; + + +@Callback(SourceCallback.class) +public interface Target { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/TargetImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/TargetImpl.java new file mode 100644 index 0000000000..86686e9233 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/java/composite/TargetImpl.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 composite; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + + +@Service(Target.class) +@Scope("COMPOSITE") +public class TargetImpl implements Target { + + private SourceCallback sourceCallback; + + @Callback + public void setSourceCallback(SourceCallback sourceCallback) { + this.sourceCallback = sourceCallback; + } + + public void someMethod(String arg) { + System.out.println("Target: " + arg); + sourceCallback.receiveResult(arg + " -> Target.someMethod"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite.composite new file mode 100644 index 0000000000..3376ac8ff5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite2.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite2.composite new file mode 100644 index 0000000000..c9eff4fa9d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/InnerComposite2.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..e675fd3624 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/META-INF/sca-contribution.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/OuterComposite.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/OuterComposite.composite new file mode 100644 index 0000000000..cb1c1e13d4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/main/resources/OuterComposite.composite @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java new file mode 100644 index 0000000000..9e9a4b44a4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-composite/src/test/java/composite/CompositeTestCase.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package composite; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class CompositeTestCase extends TestCase { + + private SCADomain scaDomain; + private Source source; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance(); + source = scaDomain.getService(Source.class, "SourceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + try { + System.out.println("Main thread " + Thread.currentThread()); + source.clientMethod("Client.main"); + System.out.println("Sleeping ..."); + Thread.sleep(1000); + } catch (Throwable t) { + t.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/README b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/README new file mode 100644 index 0000000000..5e8190648f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/README @@ -0,0 +1,83 @@ +Implementation CRUD Sample +========================== +This sample demonstrates how new implementation types are constructed for +Apache Tuscany SCA. + +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 want to try out the CRUD implementation type that this sample provides +please see the implementation-crud sample that provides the necessary client +code to bring up an application that uses this implementation extension. + +Sample Overview +--------------- +This sample contains a CRUD implementation type as an example of how to create +new implementation types. Components using this implementation type always +expose the same Create, Retrieve, Update and Delete interface. This sample +uses a singleton ResourceManager to perform the CRUD operations but of course +a real component would provide a real implementation. + +implementation-crud-extension/ + src/ + main/ + java/ + crud/ - implementation model interfaces + backend/ - fake component implementation + impl/ - implementations of the model interfaces + provider/ - runtime implementation + resources/ + META-INF/ + services/ - declares the extension + test/ + java/ + crud/ + CRUDTestCase.java - JUnit test case + resources/ + crud.composite - the SCA assembly used during unit testing + + build.xml - the Ant build file + pom.xml - the Maven build file + +Building The Sample Extension Using Ant +----------------------------------------- +With the binary distribution the sample extension can be built using Ant as +follows + +cd implementation-crud-extension +ant compile + +See the implementation-crud sample to run a sample that uses this +implementation extension. + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built +using Maven as follows. + +cd implementation-crud-extension +mvn + +Maven will also test that the sample extension built properly. You should see +the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running crud.CRUDTestCase +Starting CRUDServiceComponent +create(ABC) in tmp +retrieve(0) +update(0) +retrieve(0) +delete(0) +retrieve(0) +Stopping CRUDServiceComponent +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.212 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/build.xml new file mode 100644 index 0000000000..88d308e6fc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/pom.xml new file mode 100644 index 0000000000..bd126c8f27 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-crud-extension + Apache Tuscany CRUD Implementation Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUD.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUD.java new file mode 100644 index 0000000000..b23d85887b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUD.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 crud; + +/** + * The service interface of the single CRUD service provided by CRUD components. + */ +public interface CRUD { + + /** + * Create a new resource. + * @param resource + * @return + */ + String create(Object resource); + + /** + * Retrieve a resource. + * @param id + * @return + */ + Object retrieve(String id); + + /** + * Update a resource. + * @param id + * @param resource + * @return + */ + Object update(String id, Object resource); + + /** + * Delete a resource. + * @param id + */ + void delete(String id); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.java new file mode 100644 index 0000000000..5cb2bd2b1c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementation.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 crud; + +import org.apache.tuscany.sca.assembly.Implementation; + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +public interface CRUDImplementation extends Implementation { + + /** + * Returns the directory used by CRUD implementations to persist resources. + * + * @return the directory used to persist resources + */ + public String getDirectory(); + + /** + * Sets the directory used by CRUD implementations to persist resources. + * + * @param directory the directory used to persist resources + */ + public void setDirectory(String directory); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java new file mode 100644 index 0000000000..fa83c63c1b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/CRUDImplementationFactory.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud; + +import crud.CRUDImplementation; + + +/** + * A factory for the sample CRUD implementation model. + */ +public interface CRUDImplementationFactory { + + /** + * Creates a new CRUD implementation. + * + * @return + */ + CRUDImplementation createCRUDImplementation(); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java new file mode 100644 index 0000000000..cc0795a735 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/backend/ResourceManager.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud.backend; + +import java.util.HashMap; +import java.util.Map; + +/** + * A fake resource manager implementation used as a backend by the sample + * CRUD component implementation. + */ +public class ResourceManager { + private static int counter; + private static final Map store = new HashMap(); + private String directory; + + /** + * Constructs a new resource manager. + * + * @param directory the directory where to persist resources + */ + public ResourceManager(String directory) { + super(); + this.directory = directory; + } + + /** + * Creates a new resource. + * + * @param resource + * @return + */ + public String createResource(Object resource) { + System.out.println("create(" + resource + ") in " + directory); + String key = String.valueOf(counter++); + store.put(key, resource); + return key; + } + + /** + * Deletes a resource. + * + * @param id + */ + public void deleteResource(String id) { + System.out.println("delete(" + id + ")"); + store.remove(id); + } + + /** + * Retrieves a resource. + * + * @param id + * @return + */ + public Object retrieveResource(String id) { + System.out.println("retrieve(" + id + ")"); + return store.get(id); + } + + /** + * Updates a resource. + * + * @param id + * @param resource + * @return + */ + public Object updateResource(String id, Object resource) { + System.out.println("update(" + id + ")"); + return store.put(id, resource); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.java new file mode 100644 index 0000000000..7f9f8da674 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationFactoryImpl.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 crud.impl; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +import crud.CRUDImplementation; +import crud.CRUDImplementationFactory; + + +/** + * A default factory for the CRUD implementation model. + */ +public class CRUDImplementationFactoryImpl implements CRUDImplementationFactory { + + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaFactory; + + public CRUDImplementationFactoryImpl(ModelFactoryExtensionPoint modelFactories) { + this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + } + + public CRUDImplementation createCRUDImplementation() { + return new CRUDImplementationImpl(assemblyFactory, javaFactory); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java new file mode 100644 index 0000000000..383a035e69 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/impl/CRUDImplementationImpl.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package crud.impl; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +import crud.CRUD; +import crud.CRUDImplementation; + + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + */ +class CRUDImplementationImpl implements CRUDImplementation { + + private Service crudService; + private String directory; + + /** + * Constructs a new CRUD implementation. + */ + CRUDImplementationImpl(AssemblyFactory assemblyFactory, + JavaInterfaceFactory javaFactory) { + + // CRUD implementation always provide a single service exposing + // the CRUD interface, and have no references and properties + crudService = assemblyFactory.createService(); + crudService.setName("CRUD"); + JavaInterface javaInterface; + try { + javaInterface = javaFactory.createJavaInterface(CRUD.class); + } catch (InvalidInterfaceException e) { + throw new IllegalArgumentException(e); + } + JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + interfaceContract.setInterface(javaInterface); + crudService.setInterfaceContract(interfaceContract); + } + + public String getDirectory() { + return directory; + } + + public void setDirectory(String directory) { + this.directory = directory; + } + + public ConstrainingType getConstrainingType() { + // The sample CRUD implementation does not support constrainingTypes + return null; + } + + public List getProperties() { + // The sample CRUD implementation does not support properties + return Collections.emptyList(); + } + + public List getServices() { + // The sample CRUD implementation provides a single fixed CRUD service + return Collections.singletonList(crudService); + } + + public List getReferences() { + // The sample CRUD implementation does not support properties + return Collections.emptyList(); + } + + public String getURI() { + // The sample CRUD implementation does not have a URI + return null; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + // The sample CRUD implementation does not support constrainingTypes + } + + public void setURI(String uri) { + // The sample CRUD implementation does not have a URI + } + + public boolean isUnresolved() { + // The sample CRUD implementation is always resolved + return false; + } + + public void setUnresolved(boolean unresolved) { + // The sample CRUD implementation is always resolved + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java new file mode 100644 index 0000000000..f37d9f0c1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationInvoker.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud.provider; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +import crud.backend.ResourceManager; + + +/** + * Implements a target invoker for CRUD component implementations. + * + * The target invoker is responsible for dispatching invocations to the particular + * component implementation logic. In this example we are simply delegating the + * CRUD operation invocations to the corresponding methods on our fake + * resource manager. + */ +class CRUDImplementationInvoker implements Invoker { + private Operation operation; + private ResourceManager resourceManager; + + CRUDImplementationInvoker(Operation operation, ResourceManager resourceManager) { + this.operation = operation; + this.resourceManager = resourceManager; + } + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + Object resp = null; + + if (operation.getName().equals("create")) { + resp = resourceManager.createResource(args[0]); + + } else if (operation.getName().equals("retrieve")) { + resp = resourceManager.retrieveResource((String)args[0]); + + } else if (operation.getName().equals("update")) { + resp = resourceManager.updateResource((String)args[0], args[1]); + + } else if (operation.getName().equals("delete")) { + resourceManager.deleteResource((String)args[0]); + } + + msg.setBody(resp); + } catch (Exception e) { + msg.setFaultBody(e.getCause()); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java new file mode 100644 index 0000000000..93930d5dfe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProvider.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package crud.provider; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +import crud.CRUDImplementation; +import crud.backend.ResourceManager; + + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +class CRUDImplementationProvider implements ImplementationProvider { + + private RuntimeComponent component; + private CRUDImplementation implementation; + + /** + * Constructs a new CRUD implementation. + */ + CRUDImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { + this.component = component; + this.implementation = implementation; + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory())); + return invoker; + } + + public Invoker createCallbackInvoker(Operation operation) { + CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory())); + return invoker; + } + + public void start() { + System.out.println("Starting " + component.getName()); + } + + public void stop() { + System.out.println("Stopping " + component.getName()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.java new file mode 100644 index 0000000000..d0166d649b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/java/crud/provider/CRUDImplementationProviderFactory.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 crud.provider; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +import crud.CRUDImplementation; +import crud.provider.CRUDImplementationProvider; + + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +public class CRUDImplementationProviderFactory implements ImplementationProviderFactory { + + /** + * Constructs a new CRUD implementation. + */ + public CRUDImplementationProviderFactory(ExtensionPointRegistry extensionPoints) { + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { + return new CRUDImplementationProvider(component, implementation); + } + + public Class getModelType() { + return CRUDImplementation.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory new file mode 100644 index 0000000000..3cf5de5fa1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/crud.CRUDImplementationFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the implementation model factory +crud.impl.CRUDImplementationFactoryImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..17c98cf706 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://crud#implementation.crud,model=crud.CRUDImplementation,factory=crud.CRUDImplementationFactory diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..6ce605197a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the implementation extension +crud.provider.CRUDImplementationProviderFactory;model=crud.CRUDImplementation diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java new file mode 100644 index 0000000000..999ec4bdb6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/java/crud/CRUDTestCase.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + +/** + * Tests the CRUD service + */ +public class CRUDTestCase extends TestCase { + + private SCADomain scaDomain; + private CRUD crudService; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("crud.composite"); + crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + + public void testCRUD() throws Exception { + String id = crudService.create("ABC"); + Object result = crudService.retrieve(id); + assertEquals("ABC", result); + crudService.update(id, "EFG"); + result = crudService.retrieve(id); + assertEquals("EFG", result); + crudService.delete(id); + result = crudService.retrieve(id); + assertNull(result); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/resources/crud.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/resources/crud.composite new file mode 100644 index 0000000000..18745033bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud-extension/src/test/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/README b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/README new file mode 100644 index 0000000000..50da631c04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/README @@ -0,0 +1,113 @@ +Implementation CRUD Sample Client +================================= +This sample demonstrates how to use the new implementation extension, +implementation-crud-extension. + +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 ..\..\lib\tuscany-sca-manifest.jar;..\implementation-crud-extension\target\sample-implementation-crud-extension.jar;target\sample-implementation-crud.jar crud.client.CRUDClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:../implementation-crud-extension/target/sample-implementation-crud-extension.jar:target/sample-implementation-crud.jar crud.client.CRUDClient + +This looks like a long command. The three things we add to the classpath are + +tuscany-sca-manifest.jar - all of the standard Tuscany SCA + runtime and extension classes +sample-implementation-crud-extension.jar - the new crud implementation + extension +sample-implementation-crud.jar - the application that uses the crud + implementation + +Sample Overview +--------------- +This sample contains a client application for a CRUD implementation type that +shows how to create new implementation types. See the README for the +mplementation-crud-extension sample for details of this implementation type. + +implementation-crud/ + src/ + main/ + java/ + crud/ + client/ + CRUDClient.java - sample client + resources/ + crud.composite - the SCA assembly used by this sample + + test/ + java/ + crud/ + client/ + CRUDTestCase.java - sample JUnit test case for the sample client + + implementation-crud.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 implementation-crud +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Starting CRUDServiceComponent + [java] create(ABC) in tmp + [java] retrieve(0) + [java] Result from create: ABC + [java] update(0) + [java] retrieve(0) + [java] Result from update: EFG + [java] delete(0) + [java] retrieve(0) + [java] Result from delete: null + [java] Stopping CRUDServiceComponent + + +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 implementation-crud +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running crud.client.CRUDTestCase +Starting CRUDServiceComponent +create(ABC) in tmp +retrieve(0) +update(0) +retrieve(0) +delete(0) +retrieve(0) +Stopping CRUDServiceComponent +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.641 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/build.xml new file mode 100644 index 0000000000..10b26b5a94 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/build.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.png b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.png new file mode 100644 index 0000000000..a292037e7a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.svg b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.svg new file mode 100644 index 0000000000..dbb37be208 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/implementation-crud.svg @@ -0,0 +1,135 @@ + + + + + + + + + + image/svg+xml + + + + + + + + crud + + CRUDServiceComponent + CRUD + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/pom.xml new file mode 100644 index 0000000000..c27996539e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/pom.xml @@ -0,0 +1,64 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-crud + Apache Tuscany CRUD Implementation Extension Sample Client + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + sample-implementation-crud-extension + 0.99-incubating-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/java/crud/client/CRUDClient.java new file mode 100644 index 0000000000..e349f30fb9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/java/crud/client/CRUDClient.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 crud.client; + + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + +/** + * @version $Rev$ $Date$ + */ +public class CRUDClient { + + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("crud.composite"); + CRUD crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + + String id = crudService.create("ABC"); + Object result = crudService.retrieve(id); + System.out.println("Result from create: " + result); + crudService.update(id, "EFG"); + result = crudService.retrieve(id); + System.out.println("Result from update: " + result); + crudService.delete(id); + result = crudService.retrieve(id); + if (result == null) { + System.out.println("Result from delete: null"); + } else { + System.out.println("Result from delete: should be null but was " + result); + } + + scaDomain.close(); + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/resources/crud.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/resources/crud.composite new file mode 100644 index 0000000000..18745033bb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/main/resources/crud.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java new file mode 100644 index 0000000000..171ddbaed3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-crud/src/test/java/crud/client/CRUDTestCase.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud.client; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud.CRUD; + + +public class CRUDTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("crud.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + CRUD crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + + String id = crudService.create("ABC"); + Object result = crudService.retrieve(id); + assertEquals(result, "ABC"); + + crudService.update(id, "EFG"); + result = crudService.retrieve(id); + assertEquals(result, "EFG"); + + crudService.delete(id); + result = crudService.retrieve(id); + assertNull(result); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/README b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/README new file mode 100644 index 0000000000..9a3e74a3a2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/README @@ -0,0 +1,70 @@ +Notification Implementation Sample +=============================== + +This sample illustrates the use of + +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: + +mvn test + +Sample Overview +--------------- + +This sample consists of a single composite that contains a notification component, +a producer component and two consumer components. Take a look at the composite file +or the .svg file which shows the composite file in pictorial form. The notification +component has an that refers to the component type +that defines the TrafficAdvisory java interface. This interface indicates the +makeup of the messages being sent and received and is also implemented by the +consumer components. + +Sample directory structure: + +implementation-notification/ + src/ + main/ + java/ + notification/ + TestCaseProducer.java - interface for the producer component + TrafficAdvisory.java - interface for the notification and consumer components + TrafficAdvisoryConsumer.java - implementation for the consumer components + TrafficAdvisoryProducer.java - implementation for the producer component + test/ + java/ + notification/ + TrafficAdvisoryTestCase.java - JUnit test case + resources/ + TrafficAdvisoryNotification.componentType - the component type referred to by + + TrafficAdvisoryNotification.composite - the main composite including producer, + notification component, and consumers + pom.xml - the Maven build file + +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 implementation-notification +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running notification.TrafficAdvisoryTestCase +Consumer [Consumer1] received report: Nothing to report today +Consumer [Consumer2] received report: Nothing to report today +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.742 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/implementation-notification.png b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/implementation-notification.png new file mode 100644 index 0000000000..0b7ee34bf7 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/implementation-notification.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/pom.xml new file mode 100644 index 0000000000..7ac4866728 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/pom.xml @@ -0,0 +1,75 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-notification + Apache Tuscany Notification Implementation Sample + 0.99-incubating-SNAPSHOT + A sample illustrating use of implementation.notification + + + + org.apache.tuscany.sca + tuscany-implementation-notification + 0.99-incubating-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + test + + + + + + junit + junit + 4.2 + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + install + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java new file mode 100644 index 0000000000..bf8c72e0ce --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TestCaseProducer.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification; + +public interface TestCaseProducer { + + public void produceTrafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java new file mode 100644 index 0000000000..7bbfda2122 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisory.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification; + +public interface TrafficAdvisory { + + void trafficNotification(String report); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.java new file mode 100644 index 0000000000..2aaae596be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryConsumer.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 notification; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * @version $Rev$ $Date$ + */ +@Service(TrafficAdvisory.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryConsumer implements TrafficAdvisory { + + @Property + protected String name; + + public void trafficNotification(String report) { + + System.out.println("Consumer [" + name + "] received report: " + report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.java new file mode 100644 index 0000000000..a0bb02e846 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/main/java/notification/TrafficAdvisoryProducer.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 notification; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(TestCaseProducer.class) +@Scope("COMPOSITE") +public class TrafficAdvisoryProducer implements TestCaseProducer { + + @Reference + protected TrafficAdvisory destination; + + public void produceTrafficNotification(String report) { + + destination.trafficNotification(report); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java new file mode 100644 index 0000000000..719141c94b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/java/notification/TrafficAdvisoryTestCase.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package notification; + +import junit.framework.TestCase; + +import notification.TestCaseProducer; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class TrafficAdvisoryTestCase extends TestCase { + + private SCADomain domain; + private TestCaseProducer testCaseProducer; + + public void testTrafficAdvisoryNotification() throws Exception { + try { + testCaseProducer.produceTrafficNotification("Nothing to report today"); + } catch(Throwable e) { + e.printStackTrace(); + } + } + + @Override + protected void setUp() throws Exception { + try { + domain = SCADomain.newInstance("TrafficAdvisoryNotification.composite"); + testCaseProducer = domain.getService(TestCaseProducer.class, "TrafficAdvisoryProducer"); + } catch(Throwable e) { + e.printStackTrace(); + if (e instanceof Exception) { + throw (Exception)e; + } + else { + throw new Exception(e); + } + } + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType new file mode 100644 index 0000000000..873e200613 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.componentType @@ -0,0 +1,30 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite new file mode 100644 index 0000000000..bbf2281352 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-notification/src/test/resources/TrafficAdvisoryNotification.composite @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + Consumer1 + + + + + Consumer2 + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/README b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/README new file mode 100644 index 0000000000..3b201779e1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/README @@ -0,0 +1,70 @@ +Implementation POJO Sample +========================== +This sample demonstrates how new implementation types are constructed for +Apache Tuscany SCA. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +Sample Overview +--------------- +This sample contains a POJO implementation type as an example of how to create +new implementation types. + +implementation-pojo-extension/ + src/ + main/ + java/ + pojo/ - implementation model interfaces + impl/ - implementations of the model interfaces + provider/ - runtime implementation + resources/ + META-INF/ + services/ - declares the extension + test/ + java/ + helloworld/ + HelloWorldTestCase.java - JUnit test case + resources/ + helloworld.composite - the SCA assembly used during unit testing + + build.xml - the Ant build file + pom.xml - the Maven build file + +Building The Sample Extension Using Ant +----------------------------------------- +With the binary distribution the sample extension can be built using Ant as +follows + +cd implementation-pojo-extension +ant compile + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built +using Maven as follows. + +cd implementation-pojo-extension +mvn + +Maven will also test that the sample extension built properly. You should see +the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running helloworld.HelloWorldTestCase +Initializing POJO +Initializing POJO +Executing POJO sayHello +Initializing POJO +Initializing POJO +Executing POJO sayHello +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.616 sec + +Results : + +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/build.xml new file mode 100644 index 0000000000..78bae79859 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/pom.xml new file mode 100644 index 0000000000..18482be6e6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-pojo-extension + Apache Tuscany Java Implementation Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.java new file mode 100644 index 0000000000..7c2f5d236f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementation.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 pojo; + +import java.lang.reflect.Method; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.Implementation; + + +/** + * Represents a POJO implementation in an SCA assembly. + * + * @version $Rev$ $Date$ + */ +public interface POJOImplementation extends Implementation { + + /** + * Returns the POJO class name + * @return + */ + public String getPOJOName(); + + /** + * Sets the POJO class name + * @param pojoName + */ + public void setPOJOName(String pojoName); + + /** + * Returns the POJO class. + * @return + */ + public Class getPOJOClass(); + + /** + * Sets the POJO class. + * @param pojoClass + */ + public void setPOJOClass(Class pojoClass); + + /** + * Returns the POJO's methods. + * @return + */ + public Map getMethods(); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.java new file mode 100644 index 0000000000..bbcfb3d0dc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/POJOImplementationFactory.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 pojo; + + +/** + * Factory for the POJO implementation model. + * + * @version $Rev$ $Date$ + */ +public interface POJOImplementationFactory { + + /** + * Creates a new POJO implementation model object. + * @return a new POJO implementation model object + */ + POJOImplementation createPOJOImplementation(); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.java new file mode 100644 index 0000000000..0dad270a6c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationFactoryImpl.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 pojo.impl; + +import pojo.POJOImplementation; +import pojo.POJOImplementationFactory; + +/** + * A factory for the POJO implementation model. + * + * @version $Rev$ $Date$ + */ +public class POJOImplementationFactoryImpl implements POJOImplementationFactory { + + public POJOImplementation createPOJOImplementation() { + return new POJOImplementationImpl(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java new file mode 100644 index 0000000000..b5682673f6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationImpl.java @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package pojo.impl; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; + +import pojo.POJOImplementation; + + +/** + * Represents a POJO implementation in an SCA assembly. + * + * @version $Rev$ $Date$ + */ +class POJOImplementationImpl implements POJOImplementation { + + private String pojoName; + private Class pojoClass; + private String uri; + private Map methods; + private List services = new ArrayList(); + private List references = new ArrayList(); + private List properties = new ArrayList(); + private boolean unresolved; + + POJOImplementationImpl() { + } + + /** + * Returns the POJO class name + * @return + */ + public String getPOJOName() { + return pojoName; + } + + /** + * Sets the POJO class name + * @param pojoName + */ + public void setPOJOName(String pojoName) { + this.pojoName = pojoName; + setURI(pojoName.replace('.', '/')); + } + + /** + * Returns the POJO class. + * @return + */ + public Class getPOJOClass() { + return pojoClass; + } + + /** + * Sets the POJO class. + * @param pojoClass + */ + public void setPOJOClass(Class pojoClass) { + this.pojoClass = pojoClass; + setPOJOName(pojoClass.getName()); + + // Index the POJO's methods + methods = new HashMap(); + Method[] m = pojoClass.getMethods(); + for (int i = 0; i < m.length; i++) { + methods.put(m[i].getName(), m[i]); + } + } + + /** + * Returns the POJO's methods. + * @return + */ + public Map getMethods() { + return methods; + } + + public ConstrainingType getConstrainingType() { + // The sample POJO implementation does not support constrainingTypes + return null; + } + + public List getProperties() { + return properties; + } + + public List getServices() { + return services; + } + + public List getReferences() { + return references; + } + + public String getURI() { + return uri; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + // The sample POJO implementation does not support constrainingTypes + } + + public void setURI(String uri) { + this.uri = uri; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean unresolved) { + this.unresolved = unresolved; + } + + @Override + public int hashCode() { + return uri.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof POJOImplementationImpl) { + return ((POJOImplementationImpl)obj).getURI().equals(uri); + } else { + return false; + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java new file mode 100644 index 0000000000..51480d5de5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/impl/POJOImplementationProcessor.java @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package pojo.impl; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ClassReference; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +import pojo.POJOImplementation; +import pojo.POJOImplementationFactory; + +/** + * Implements a STAX based artifact processor for POJO implementations. + * + * The artifact processor is responsible for processing + * elements in SCA assembly XML composite files and populating the POJO + * implementation model, resolving its references to other artifacts in the SCA + * contribution, and optionally write the model back to SCA assembly XML. + */ +public class POJOImplementationProcessor implements StAXArtifactProcessor { + private static final QName IMPLEMENTATION_POJO = new QName("http://pojo", "implementation.pojo"); + + private AssemblyFactory assemblyFactory; + private JavaInterfaceFactory javaFactory; + private POJOImplementationFactory pojoImplementationFactory; + + public POJOImplementationProcessor(ModelFactoryExtensionPoint modelFactories) { + + // Get the assembly and Java interface factories as we'll need them to + // create model objects + assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class); + pojoImplementationFactory = modelFactories.getFactory(POJOImplementationFactory.class); + } + + public QName getArtifactType() { + // Returns the qname of the XML element processed by this processor + return IMPLEMENTATION_POJO; + } + + public Class getModelType() { + // Returns the type of model processed by this processor + return POJOImplementation.class; + } + + public POJOImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + + // Read an element + + // Read the POJO class attribute. + String className = reader.getAttributeValue(null, "class"); + + // Create the POJO implementation model + POJOImplementation implementation = pojoImplementationFactory.createPOJOImplementation(); + implementation.setPOJOName(className); + + // Mark the POJO model unresolved to track the fact that it's not + // completely initialized, its class is not loaded yet and services + // and references not initialized either + implementation.setUnresolved(true); + + // Skip to end element + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && IMPLEMENTATION_POJO.equals(reader.getName())) { + break; + } + } + + return implementation; + } + + public void resolve(POJOImplementation implementation, ModelResolver resolver) throws ContributionResolveException { + + // Resolve the POJO implementation + + // First resolve its class + ClassReference classReference = new ClassReference(implementation.getPOJOName()); + classReference = resolver.resolveModel(ClassReference.class, classReference); + Class pojoClass = classReference.getJavaClass(); + if (pojoClass == null) { + throw new ContributionResolveException("Class could not be resolved: " + implementation.getPOJOName()); + } + implementation.setPOJOClass(pojoClass); + + // Check to see if we have a .componentType file describing the POJO class + ComponentType componentType = assemblyFactory.createComponentType(); + componentType.setUnresolved(true); + componentType.setURI(implementation.getURI() + ".componentType"); + componentType = resolver.resolveModel(ComponentType.class, componentType); + if (!componentType.isUnresolved()) { + + // We have a component type description, merge it into the POJO model + implementation.getServices().addAll(componentType.getServices()); + implementation.getReferences().addAll(componentType.getReferences()); + implementation.getProperties().addAll(componentType.getProperties()); + + } else { + + // We have no component type description, simply introspect the POJO and + // create a single Service for it + Service service = assemblyFactory.createService(); + service.setName(pojoClass.getSimpleName()); + JavaInterface javaInterface; + try { + javaInterface = javaFactory.createJavaInterface(pojoClass); + } catch (InvalidInterfaceException e) { + throw new ContributionResolveException(e); + } + JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + interfaceContract.setInterface(javaInterface); + service.setInterfaceContract(interfaceContract); + implementation.getServices().add(service); + } + + // Mark the implementation resolved now + implementation.setUnresolved(false); + } + + public void write(POJOImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException { + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java new file mode 100644 index 0000000000..dbe956b8c6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationInvoker.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package pojo.provider; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.osoa.sca.ServiceRuntimeException; + +class POJOImplementationInvoker implements Invoker { + + private Object pojoInstance; + private Method method; + + POJOImplementationInvoker(Object pojoInstance, Operation operation, Method method) { + this.pojoInstance = pojoInstance; + this.method = method; + } + + public Message invoke(Message msg) { + try { + msg.setBody(method.invoke(pojoInstance, (Object[])msg.getBody())); + } catch (InvocationTargetException e) { + msg.setFaultBody(e); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java new file mode 100644 index 0000000000..b764148b67 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProvider.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package pojo.provider; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.osoa.sca.ServiceRuntimeException; + +import pojo.POJOImplementation; + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +class POJOImplementationProvider implements ImplementationProvider { + + private POJOImplementation implementation; + private Object pojoInstance; + + /** + * Constructs a new CRUD implementation. + */ + POJOImplementationProvider(RuntimeComponent component, POJOImplementation implementation) { + this.implementation = implementation; + + // Create a new instance of the POJO + try { + pojoInstance = implementation.getPOJOClass().newInstance(); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + + public void start() { + try { + // Invoke the POJO's init method + Method initMethod = implementation.getMethods().get("init"); + if (initMethod != null) { + initMethod.invoke(pojoInstance); + } + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + + public void stop() { + try { + // Invoke the POJO's destroy method + Method destroyMethod = implementation.getMethods().get("destroy"); + if (destroyMethod != null) { + destroyMethod.invoke(pojoInstance); + } + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } finally { + pojoInstance = null; + } + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + Method method = implementation.getMethods().get(operation.getName()); + POJOImplementationInvoker invoker = new POJOImplementationInvoker(pojoInstance, operation, method); + return invoker; + } + + public Invoker createCallbackInvoker(Operation operation) { + Method method = implementation.getMethods().get(operation.getName()); + POJOImplementationInvoker invoker = new POJOImplementationInvoker(pojoInstance, operation, method); + return invoker; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.java new file mode 100644 index 0000000000..ce135b64cf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/java/pojo/provider/POJOImplementationProviderFactory.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 pojo.provider; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +import pojo.POJOImplementation; + +/** + * The model representing a sample POJO implementation in an SCA assembly model. + */ +public class POJOImplementationProviderFactory implements ImplementationProviderFactory { + + public POJOImplementationProviderFactory(ExtensionPointRegistry registry) { + } + + public Class getModelType() { + // Returns the type of model processed by this processor + return POJOImplementation.class; + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, POJOImplementation implementation) { + return new POJOImplementationProvider(component, implementation); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..8337e81c5f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +pojo.impl.POJOImplementationProcessor;qname=http://pojo#implementation.pojo,model=pojo.POJOImplementation,factory=pojo.POJOImplementationFactory diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..b30ea3b9cf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the implementation extension +pojo.provider.POJOImplementationProviderFactory;model=pojo.POJOImplementation diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory new file mode 100644 index 0000000000..075af98240 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/main/resources/META-INF/services/pojo.POJOImplementationFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for implementation model factory +pojo.impl.POJOImplementationFactoryImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..cc32929f09 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorld.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +public interface HelloWorld { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..0580e30aba --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +public class HelloWorldImpl { + + public void init() { + System.out.println("Initializing POJO"); + } + + public void destroy() { + System.out.println("Destroying POJO"); + } + + public String sayHello(String name) { + System.out.println("Executing POJO sayHello"); + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java new file mode 100644 index 0000000000..69ab1f567e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldImpl2.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +public class HelloWorldImpl2 { + + public void init() { + System.out.println("Initializing POJO"); + } + + public void destroy() { + System.out.println("Destroying POJO"); + } + + public String sayHello(String name) { + System.out.println("Executing POJO sayHello"); + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..b2a676be49 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/java/helloworld/HelloWorldTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + */ +public class HelloWorldTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("helloworld/helloworld.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testHello() throws Exception { + HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent"); + assertEquals("Hello petra", helloworld.sayHello("petra")); + } + + public void testHello2() throws Exception { + HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent2/HelloWorld2"); + assertEquals("Hello petra", helloworld.sayHello("petra")); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType new file mode 100644 index 0000000000..a92c5ab8db --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/HelloWorldImpl2.componentType @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..c38094dfc9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/implementation-pojo-extension/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/pom.xml new file mode 100644 index 0000000000..96485ba8ad --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-loanapplication + Apache Tuscany Loan Application Conversation Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplication.java new file mode 100644 index 0000000000..4fedb70782 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplication.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 loanapplication; + +public class LoanApplication { + + private String customerName; + private float loanAmount; + + public LoanApplication(String customerName, float loanAmount) { + this.customerName = customerName; + this.loanAmount = loanAmount; + } + + @Override + public String toString() { + return "[Customer: " + customerName + ", loan amount: " + + loanAmount + "]"; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java new file mode 100644 index 0000000000..5183ece867 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanApplicationClient.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package loanapplication; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + + +public class LoanApplicationClient { + + public static void main(String[] args) throws Exception { + SCADomain domain = SCADomain.newInstance("loanapplication.composite"); + + // Locate the MyClient component and invoke it + LoanClient loanClient = domain.getService(LoanClient.class, "LoanClientComponent"); + loanClient.applyForLoan("John Doe", 1000.0f); + System.out.println(loanClient.displayLoan()); + System.out.println("Loan approved: " + loanClient.isApproved()); + + domain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClient.java new file mode 100644 index 0000000000..7e4438bbff --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClient.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 loanapplication; + +public interface LoanClient { + + void applyForLoan(String customerName, float amount); + boolean isApproved(); + boolean isCancelled(); + String displayLoan(); + void cancelLoan(); + void closeLoan(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java new file mode 100644 index 0000000000..b06d9465a2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanClientImpl.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package loanapplication; + + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; + +@Scope("COMPOSITE") +public class LoanClientImpl implements LoanClient { + + private LoanService loanService; + + @Reference + public void setLoanService(LoanService loanService) { + this.loanService = loanService; + } + + public void applyForLoan(String customerName, float amount) { + loanService.apply(new LoanApplication(customerName, amount)); + } + + public boolean isApproved() { + if (loanService.getLoanStatus() == null) { + return false; + } + return loanService.getLoanStatus().equals("approved"); + } + + public boolean isCancelled() { + if (loanService.getLoanStatus() == null) { + return false; + } + return loanService.getLoanStatus().equals("cancelled"); + } + + public String displayLoan() { + return loanService.display(); + } + + public void cancelLoan() { + loanService.cancelApplication(); + } + + public void closeLoan() { + loanService.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanService.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanService.java new file mode 100644 index 0000000000..9dfd8b42fe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanService.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package loanapplication; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.EndsConversation; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +@Conversational +@Remotable +public interface LoanService { + + void apply(LoanApplication application); + + void lockCurrentRate(int termInYears); + + @OneWay + void cancelApplication(); + + String getLoanStatus(); + + String display(); + + @EndsConversation + void close(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.java new file mode 100644 index 0000000000..76a53323bd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/java/loanapplication/LoanServiceImpl.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 loanapplication; + +import org.osoa.sca.annotations.AllowsPassByReference; +import org.osoa.sca.annotations.ConversationID; +import org.osoa.sca.annotations.Scope; + +@Scope("CONVERSATION") +@AllowsPassByReference +public class LoanServiceImpl implements LoanService { + + private LoanApplication application; + private String status; + private int termLocked = 0; + @ConversationID + protected String conversationID; + + public void apply(LoanApplication application) { + this.application = application; + status = "open"; + } + + public void lockCurrentRate(int termInYears) { + termLocked = termInYears; + status = "locked"; + } + + public void cancelApplication() { + status = "cancelled"; + } + + public String getLoanStatus() { + return status; + } + + public String display() { + return "Loan application: " + application + ", term: " + + termLocked + ", status: " + status + + ", conversationID: " + conversationID; + } + + public void close() { + this.application = null; + this.status = "closed"; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/resources/loanapplication.composite b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/resources/loanapplication.composite new file mode 100644 index 0000000000..3aa8d030b7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/main/resources/loanapplication.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java new file mode 100644 index 0000000000..e88e48a53a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/loanapplication/src/test/java/loanapplication/LoanApplicationTestCase.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package loanapplication; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class LoanApplicationTestCase extends TestCase { + + private LoanClient loanClient; + private SCADomain domain; + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("loanapplication.composite"); + + loanClient = domain.getService(LoanClient.class, "LoanClientComponent"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + + public void test() throws Exception { + try { + loanClient.applyForLoan("John Doe", 1000.0f); + System.out.println("Applied: " + loanClient.displayLoan()); + System.out.println("Loan approved: " + loanClient.isApproved()); + loanClient.cancelLoan(); + System.out.println("Sleeping to let cancel complete ..."); + Thread.sleep(500); + if (!loanClient.isCancelled()) { + fail("Loan should be cancelled"); + } + System.out.println("Cancelled: " + loanClient.displayLoan()); + loanClient.closeLoan(); + + /* This is a mistake, after @EndsConversation, a new conversation is + * started automatically, so we should not get TargetNotFoundException. + * Keep this for the timeout case, where we should get the exception + try { + System.out.println("Trying to use the closed loan in the ended conversation ..."); + System.out.println("Closed: " + loanClient.displayLoan()); + fail("Target should not be found"); + } catch(TargetNotFoundException e) { + System.out.println("Target not found as expected"); + } + */ + + // Now check that a new conversation's loan is not cancelled + + if (loanClient.isCancelled()) { + fail("Loan should not be cancelled"); + } + } catch(Throwable e) { + e.printStackTrace(); + if (e instanceof Exception) { + throw (Exception)e; + } + if (e instanceof Error) { + throw (Error)e; + } + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/pom.xml new file mode 100644 index 0000000000..991935e07b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/pom.xml @@ -0,0 +1,178 @@ + + + + + org.apache.tuscany.samples.bigbank + bigbank-scenario + 0.1-integration-incubating-SNAPSHOT + + 4.0.0 + sample-bigbank-account + war + Tuscany BigBank Account Module + BigBank Scenario - Account Management Module + + + + + org.apache.tuscany.sca.kernel + tuscany-api + ${scaKernelVersion} + compile + + + org.apache.tuscany.sca.runtime.webapp + webapp-api + ${scaKernelVersion} + runtime + + + + + stax + stax-api + 1.0.1 + compile + + + + org.codehaus.woodstox + wstx-asl + 3.2.0 + runtime + + + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubatingversion> + compile + + + + + org.apache.tuscany.das + tuscany-das-rdb + ${dasVersion} + compile + + + javax.servlet + servlet-api + 2.5 + provided + + + org.apache.derby + derby + 10.1.2.1 + compile + + + junit + junit + 4.2 + test + + + + ${artifactId} + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.0-incubating + + + + + ${basedir}/src/main/resources/wsdl + true + true + true + + + generate + + + + + + org.apache.tuscany.sca.extensions.axis2.plugins + tuscany-plugin-wsdl2java + ${scaKernelVersion} + + + + + + ${basedir}/src/main/resources/wsdl/stockquotes.webservicex.wsdl + + StockQuoteSoap + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + + + + + generate + + + + + + org.apache.tuscany.sca.runtime.webapp + tuscany-war-plugin + ${scaKernelVersion} + + + tuscany-war + + tuscany-war + + + + + + + false + + + + org.apache.tuscany.sca.services.databinding + databinding-sdo + ${scaKernelVersion} + + + org.apache.tuscany.sca.extensions.axis2 + tuscany-axis2 + ${scaKernelVersion} + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java new file mode 100644 index 0000000000..74baa636f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/account/AccountServiceImpl.java @@ -0,0 +1,279 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.account.services.account; + +import java.rmi.RemoteException; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.services.accountdata.AccountDataService; +import bigbank.account.services.stockquote.StockQuote; +import bigbank.account.services.stockquote.StockQuoteService; + +import com.bigbank.account.AccountLog; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +@Service(interfaces = AccountService.class) +public class AccountServiceImpl implements AccountService { + + public static final String CHECKING_ACCOUNT_PREFIX = "134-43-394"; + + public static final String SAVINGS_ACCOUNT_PREFIX = "134-42-623"; + + public static final String ACCOUNT_TYPE_SAVINGS = "savings"; + + public static final String ACCOUNT_TYPE_CHECKINGS = "checkings"; + + public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); + static { + AccountServiceImpl.tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC")); + } + + private float currencyConversion = 0.0f; + + private String currency = "USD"; + + @Property + public void setCurrency(final String currency) { + this.currency = currency; + } + + float getCurrencyConversion() { + if (currencyConversion == 0.0F) { + if ("USD".equals(currency)) { + currencyConversion = 1.0f; + } else if ("EURO".equals(currency)) { + currencyConversion = 0.8f; + } else { + try { + currencyConversion = Float.parseFloat(currency); + } catch (Exception e) { + currencyConversion = 1.0f; + } + + } + + } + return currencyConversion; + + } + + private AccountDataService accountDataService; + + @Reference + public void setAccountDataService(AccountDataService accountDataService) { + this.accountDataService = accountDataService; + } + + private StockQuoteService stockQuoteService; + + @Reference + public void setStockQuoteService(StockQuoteService stockQuoteService) { + this.stockQuoteService = stockQuoteService; + } + + public AccountServiceImpl() { + } + + @SuppressWarnings("unchecked") + public AccountReport getAccountReport(int customerID) throws RemoteException { + + try { + AccountReport accountReport = accountDataService.getAccountReport(customerID); + // convert to local currency. + List accounts = accountReport.getAccountSummaries(); + for (AccountSummary accountSummary : accounts) { + accountSummary.setBalance(fromUSDollarToCurrency(accountSummary.getBalance())); + + } + return updateStockInformation(accountReport); + } catch (Exception e) { + e.printStackTrace(); + if (e instanceof RemoteException) { + throw (RemoteException) e; + } else { + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + } + + private AccountReport updateStockInformation(AccountReport accountReport) throws RemoteException { + List stocks = accountReport.getStockSummaries(); + if (stocks.size() < 1) { + return accountReport; // nothing todo + } + HashSet owned = new HashSet(stocks.size()); + for (StockSummary stock : stocks) { + owned.add(stock.getSymbol()); + } + ArrayList ownedStr = new ArrayList(owned.size() * 5); + for (String s : owned) { + + ownedStr.add(s); + } + + Map stockInfo = stockQuoteService.getQuotes(ownedStr.toArray(new String[owned.size()])); + + for (StockSummary stock : stocks) { + String symbol = stock.getSymbol(); + StockQuote stockquote = stockInfo.get(symbol); + if (stockquote == null) { + stock.setCurrentPrice(Float.NaN); + stock.setCompany("*not found*"); + stock.setHighPrice(Float.NaN); + stock.setLowPrice(Float.NaN); + + } else { + stock.setCurrentPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getStockQuote()))); + stock.setCompany(stockquote.getCompanyName()); + stock.setHighPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayHighPrice()))); + stock.setLowPrice(fromUSDollarToCurrency(convertToFloat(stockquote.getDayLowPrice()))); + } + } + + return accountReport; + } + + float convertToFloat(final String s) { + + try { + return Float.parseFloat(s); + } catch (Exception e) { + return Float.NaN; + } + + } + + private float fromUSDollarToCurrency(float value) { + return value * getCurrencyConversion(); + + } + + private float toUSDollarfromCurrency(float value) { + + return value / getCurrencyConversion(); + } + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + + try { + return accountDataService.getCustomerProfile(logonID); + } catch (Exception e) { + e.printStackTrace(); + if (e instanceof RemoteException) { + throw (RemoteException) e; + } else { + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + } + + public float deposit(String account, float ammount) throws RemoteException { + try { + return accountDataService.deposit(account, toUSDollarfromCurrency(ammount)); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException { + try { + String symbol = stock.getSymbol(); + Map stockInfo = stockQuoteService.getQuotes(new String[] { symbol }); + + StockQuote stockQuote = stockInfo.get(symbol); + stock.setPurchasePrice(Float.parseFloat(stockQuote.getStockQuote())); + String purchaseDate = tsformatXSDDateTime.format(new Date()); + if (purchaseDate.endsWith("UTC")) { + purchaseDate = purchaseDate.substring(0, purchaseDate.length() - 3) + "Z"; + } + stock.setPurchaseDate(purchaseDate); + + return accountDataService.purchaseStock(id, stock); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + return accountDataService.sellStock(purchaseLotNumber, quantity); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public float withdraw(String account, float ammount) throws RemoteException { + try { + return accountDataService.withdraw(account, toUSDollarfromCurrency(ammount)); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + try { + return accountDataService.createAccount(customerProfile, createSavings, createCheckings); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public AccountLog getAccountLog(final int customerID) throws RemoteException { + return accountDataService.getAccountLog(customerID); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java new file mode 100644 index 0000000000..884127cd9e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataService.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountdata; + +public interface AccountDataService { + + /** + * Auto generated method signatures + * + * @param param0* + * @param param1* + * @param param2 + */ + public com.bigbank.account.StockSummary purchaseStock(int param0, com.bigbank.account.StockSummary parm1) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param4 + */ + public com.bigbank.account.CustomerProfileData getCustomerProfile(java.lang.String param4) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param6* + * @param param7 + */ + public float deposit(java.lang.String param6, float param7) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param9* + * @param param10* + * @param param11 + */ + public com.bigbank.account.CustomerProfileData createAccount(com.bigbank.account.CustomerProfileData param9, boolean param10, boolean param11) + throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param13* + * @param param14 + */ + public com.bigbank.account.StockSummary sellStock(int param13, int param14) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param16* + * @param param17 + */ + public float withdraw(java.lang.String param16, float param17) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param19 + */ + public com.bigbank.account.AccountReport getAccountReport(int param19) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param0 + */ + public com.bigbank.account.AccountLog getAccountLog(int param0) throws java.rmi.RemoteException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java new file mode 100644 index 0000000000..c346a3221f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java @@ -0,0 +1,400 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountdata; + +import java.io.InputStream; +import java.rmi.RemoteException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.List; +import java.util.Properties; +import java.util.TimeZone; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.Converter; +import org.apache.tuscany.das.rdb.DAS; +import org.osoa.sca.annotations.Service; + +import bigbank.account.services.account.AccountServiceImpl; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; +import commonj.sdo.DataObject; + +@Service(CustomerIdService.class) +public class AccountDataServiceDASImpl implements CustomerIdService { // TODO fix this! + + static public String dbDirectory = null; + + public static final DateFormat tsformatXSDDateTime = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSz"); + + public static final DateFormat sqlformatDateTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSz"); + + static { + tsformatXSDDateTime.setTimeZone(TimeZone.getTimeZone("UTC")); + + } + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + + try { + InputStream mapping = createConfigStream(); + Connection conn = getConnection(); + DAS das = DAS.FACTORY.createDAS(mapping, conn); + + Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = ?"); + + select.setParameter(1, logonID); + + DataObject root = select.executeQuery(); + conn.close(); + + Collection customers = root.getList("CustomerProfileData"); + CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next(); + + return customerProfileData; + } catch (Exception e) { + + e.printStackTrace(); + RemoteException re = new RemoteException("Failed to get customer profile'" + logonID + "' ", e); + re.printStackTrace(); + throw re; + } + } + + protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + + protected static final String protocol = "jdbc:derby:"; + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + + try { + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into customers (firstName,lastName,address,email, loginID, password ) values ('" + + customerProfile.getFirstName() + "', '" + customerProfile.getLastName() + "', '" + customerProfile.getAddress() + "', '" + + customerProfile.getEmail() + "', '" + customerProfile.getLoginID() + "', '" + customerProfile.getPassword() + "')"); + + insert.execute(); + CustomerProfileData ret = getCustomerProfile(customerProfile.getLoginID()); + String cid = ret.getId() + ""; + if (createSavings) { + insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '" + + AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_SAVINGS + "', " + 1.0F + ")"); + insert.execute(); + + } + if (createCheckings) { + insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '" + + AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS + "', " + 1.0F + ")"); + insert.execute(); + + } + + return ret; + } catch (Exception e) { + if (e instanceof RemoteException) { + throw (RemoteException) e; + } + throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + } + + public CustomerProfileData createAccountNOTWORKING(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + try { + DAS das = DAS.FACTORY.createDAS(createConfigStream(), getConnection()); + Command read = das.getCommand("all customers"); + + // select.setDataObjectModel(); + DataObject root = read.executeQuery(); + + // Create a new stockPurchase + DataObject customer = root.createDataObject("customerProfileData"); + + // THIS SEEMS TO BE THE ONLY WAY TO DO THIS .. NO WAY TO JUST ADD AN EXISTING CUSTOMER. + customer.set("firstName", customerProfile.getFirstName()); + customer.set("lastName", customerProfile.getLastName()); + customer.set("address", customerProfile.getAddress()); + customer.set("email", customerProfile.getEmail()); + customer.set("loginID", customerProfile.getLoginID()); + customer.set("password", customerProfile.getPassword()); + + das.applyChanges(root); + return getCustomerProfile(customerProfile.getLoginID()); + + } catch (Exception e) { + if (e instanceof RemoteException) { + throw (RemoteException) e; + } + throw new RemoteException("createAccount " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + + } + + public AccountReport getAccountReport(final int customerID) throws RemoteException { + try { + final AccountFactory accountFactory = AccountFactory.INSTANCE; + final AccountReport accountReport = accountFactory.createAccountReport(); + InputStream mapping = createConfigStream(); + + Connection conn = getConnection(); + DAS das = DAS.FACTORY.createDAS(mapping, conn); + + Command select = das.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = ?"); + select.setParameter(1, customerID); + + DataObject root = select.executeQuery(); + accountReport.getAccountSummaries().addAll(root.getList("AccountSummary")); + + // Get Stocks + + select = das.createCommand("SELECT Symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id = ?"); + select.setParameter(1, customerID); + + // select.addConverter("STOCKS.PURCHASEDATE", DateConverter.class.getName()); + + root = select.executeQuery(); + accountReport.getStockSummaries().addAll(root.getList("StockSummary")); + + conn.close(); + + return accountReport; + } catch (Exception e) { + if (e instanceof RemoteException) { + throw (RemoteException) e; + } + throw new RemoteException("getAccountReport failed. customerID ('" + customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(), + e); + } + } + + public float withdraw(String account, float ammount) throws RemoteException { + + return deposit(account, -ammount); + } + + public float deposit(String account, float ammount) throws RemoteException { + + try { + Connection conn = getConnection(); + DAS das = DAS.FACTORY.createDAS(createConfigStream(), conn); + + Command select = das.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = ?"); + select.setParameter(1, account); + + DataObject root = select.executeQuery(); + Collection accounts = root.getList("AccountSummary"); + AccountSummary accountData = (AccountSummary) accounts.iterator().next(); + float newbalance = accountData.getBalance() + ammount; + accountData.setBalance(newbalance); + // update department set companyid = ? where department.name = ? + + Command update = das.getCommand("update balance"); + update.setParameter(1, new Float(newbalance)); + update.setParameter(2, account); + update.execute(); + conn.close(); + return newbalance; + } catch (Exception e) { + throw new RemoteException(e.getClass().getName(), e); + } + + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + DAS das = DAS.FACTORY.createDAS(createConfigStream(), getConnection()); + + Command read = das.getCommand("stockbylotSelect"); + read.setParameter(1, purchaseLotNumber);// autoboxing :-) + DataObject root = read.executeQuery(); + List stocks = root.getList("StockSummary"); + if (null != stocks && !stocks.isEmpty()) { + StockSummary stock = (StockSummary) stocks.get(0); + int newQuatity = Math.max(stock.getQuantity() - quantity, 0); + if (newQuatity < 1) { + + Command delete = das.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?"); + delete.setParameter(1, purchaseLotNumber); + delete.execute(); + + } else { + + Command update = das.getCommand("stockbylot"); + + update.setParameter(1, newQuatity); + update.setParameter(2, purchaseLotNumber); + update.execute(); + + stock.setQuantity(newQuatity); + } + return stock; + } + + return null; + } catch (Exception e) { + throw new RemoteException("sellStock", e); + } + } + + public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException { + + try { + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)"); + insert.setParameter(1, new Integer(id)); + insert.setParameter(2, stock.getSymbol()); + insert.setParameter(3, stock.getQuantity()); + insert.setParameter(4, stock.getPurchasePrice()); + insert.setParameter(5, DateConverter.INSTANCE.getColumnValue(stock.getPurchaseDate())); + + insert.execute(); + + return stock; + } catch (Exception e) { + if (e instanceof RemoteException) { + throw (RemoteException) e; + } + throw new RemoteException("purchaseStock " + e.getClass().getName() + "'. " + e.getMessage(), e); + } + } + + protected Connection getConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { + Connection conn; + Class.forName(driver).newInstance(); + Properties props = new Properties(); + // props.put("user", "tuscany"); + // props.put("password", "tuscany"); + conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props); + + conn.setAutoCommit(false); + return conn; + } + + protected InputStream createConfigStream() { + InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml"); + return mapping; + } + + public static class DateConverter implements Converter { + public final static DateConverter INSTANCE = new DateConverter(); + + public DateConverter() { // public empty constructor + } + + public Object getPropertyValue(Object columnData) { + + try { + + String ret = tsformatXSDDateTime.format(columnData); + if (ret.endsWith("UTC")) { + ret = ret.substring(0, ret.length() - 3) + "Z"; + } + return ret; + + } catch (Exception e) { + + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + + } + + public Object getColumnValue(Object propertyData) { + + if (propertyData instanceof java.util.Date) { + // Need to convert back to local time for DB and remove timezone notation at the end.. + String ret = sqlformatDateTime.format(propertyData); + char lc = ret.charAt(ret.length() - 1); + while (!Character.isDigit(lc)) { + ret = ret.substring(0, ret.length() - 1); + lc = ret.charAt(ret.length() - 1); + } + return ret; + } else if (propertyData instanceof String) { + + try { + String time = (String) propertyData; + char last = time.charAt(time.length() - 1); + if (last == 'z' || last == 'Z') { + time = time.substring(0, time.length() - 1); + } + if (!time.endsWith("UTC")) { + time = time + "UTC"; + } + return getColumnValue(tsformatXSDDateTime.parse(time)); + } catch (ParseException e) { + throw new IllegalArgumentException("'" + propertyData + "' does not parse to date."); + } + } else { + throw new IllegalArgumentException(); + } + + } + + } + + public int getCustomerIdByPurchaseLotNumber(int purchaseLotNumber) throws RemoteException { + + return queryCustomerId("select id from stocks where purchaseLotNumber = " + purchaseLotNumber); + } + + public int getCustomerIdByAccount(String account) throws RemoteException { + + return queryCustomerId("select id from accounts where accountNumber = '" + account + "'"); + } + + private int queryCustomerId(String query) throws RemoteException { + + try { + Connection conn = getConnection(); + + Statement s = conn.createStatement(); + + ResultSet rs = s.executeQuery(query); + int id = -1; + if (rs.next()) { + id = rs.getInt("id"); + } + + conn.commit(); + + rs.close(); + s.close(); + conn.close(); + + return id; + + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass().getName(), e); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..5e08cf634f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceImpl.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountdata; + +import java.rmi.RemoteException; +import java.util.List; + +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountLog; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +@Service(AccountDataService.class) +public class AccountDataServiceImpl implements AccountDataService { + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public AccountReport getAccountReport(int customerID) { + final AccountFactory accountFactory = AccountFactory.INSTANCE; + AccountReport accountReport = accountFactory.createAccountReport(); + List accounts = accountReport.getAccountSummaries(); + + AccountSummary account = accountFactory.createAccountSummary(); + account.setAccountType("1111"); + account.setAccountNumber("22-22-22"); + account.setBalance(123.45F); + accounts.add(account); + + account = accountFactory.createAccountSummary(); + account.setAccountType("04-11-19"); + account.setAccountNumber("11-23"); + account.setBalance(543.21F); + accounts.add(account); + + List stocks = accountReport.getStockSummaries(); + StockSummary stock = accountFactory.createStockSummary(); + stock.setSymbol("IBM"); + stock.setPurchaseDate("1999-11-23"); + stock.setPurchaseLotNumber(101); + stock.setPurchasePrice(33.33F); + stock.setQuantity(10); + stocks.add(stock); + + stock = accountFactory.createStockSummary(); + stock.setSymbol("TUSK"); + stock.setPurchaseDate("2005-01-05"); + stock.setPurchaseLotNumber(102); + stock.setPurchasePrice(11.11F); + stock.setQuantity(4); + stocks.add(stock); + return accountReport; + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public float deposit(String param6, float param7) throws RemoteException { + // TODO Auto-generated method stub + return 0; + } + + public StockSummary purchaseStock(int param0, StockSummary stock) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public StockSummary sellStock(int param13, int param14) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + public float withdraw(String param16, float param17) throws RemoteException { + // TODO Auto-generated method stub + return 0; + } + + public AccountLog getAccountLog(final int customerID) throws RemoteException { + throw new RemoteException("This method should not be called"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java new file mode 100644 index 0000000000..b355a09008 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdata/CustomerIdService.java @@ -0,0 +1,98 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountdata; + +import java.rmi.RemoteException; + +/** + * This interface allows access to a customer's id from the data service. + */ +public interface CustomerIdService { + + /* + * Return -1 if purchaseLotNumber not found + */ + public int getCustomerIdByPurchaseLotNumber(int purchaseLotNumber) throws RemoteException; + + /* + * Return -1 if account not found + */ + public int getCustomerIdByAccount(String account) throws RemoteException; + + // TODO (isilval) Fix this !!! + // Apparently, configuration can't deal with extends so I am adding the contents of AccountDataService here + + /** + * Auto generated method signatures + * + * @param param0* + * @param param1* + * @param param2 + */ + public com.bigbank.account.StockSummary purchaseStock(int param0, com.bigbank.account.StockSummary parm1) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param4 + */ + public com.bigbank.account.CustomerProfileData getCustomerProfile(java.lang.String param4) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param6* + * @param param7 + */ + public float deposit(java.lang.String param6, float param7) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param9* + * @param param10* + * @param param11 + */ + public com.bigbank.account.CustomerProfileData createAccount(com.bigbank.account.CustomerProfileData param9, boolean param10, boolean param11) + throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param13* + * @param param14 + */ + public com.bigbank.account.StockSummary sellStock(int param13, int param14) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param16* + * @param param17 + */ + public float withdraw(java.lang.String param16, float param17) throws java.rmi.RemoteException; + + /** + * Auto generated method signatures + * + * @param param19 + */ + public com.bigbank.account.AccountReport getAccountReport(int param19) throws java.rmi.RemoteException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java new file mode 100644 index 0000000000..1225c95f84 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java @@ -0,0 +1,465 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountdb; + +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collection; +import java.util.Date; +import java.util.Properties; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.Converter; +import org.apache.tuscany.das.rdb.DAS; +import org.apache.tuscany.das.rdb.config.ConfigFactory; +import org.apache.tuscany.sdo.util.SDOUtil; + +import bigbank.account.services.account.AccountServiceImpl; +import bigbank.account.services.accountdata.AccountDataServiceDASImpl; +import bigbank.account.services.accountlogger.AccountLoggerServiceImpl; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountSummary; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; +import commonj.sdo.DataObject; +import com.bigbank.account.purchaseStock; +import com.bigbank.account.withdraw; + +public class AccountDBInit extends HttpServlet { + + private static final long serialVersionUID = -4795999792460944805L; + + protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + + protected static final String protocol = "jdbc:derby:"; + + protected String dbDirectory = null; + + protected String dasConfigFile = null; + + boolean deleteExisting = false; + + @Override + public void init() throws ServletException { + try { + + registerTypes(); + ServletConfig servletConfig = getServletConfig(); + ServletContext servletContext = servletConfig.getServletContext(); + dbDirectory = servletContext.getRealPath("WEB-INF/bigbankdb/accounts"); + dasConfigFile = servletContext.getRealPath("WEB-INF/classes/DasAccountConfiguration.xml"); + deleteExisting = false; + + createDB(dbDirectory); + + } catch (Exception e) { + + e.printStackTrace(); + log(e.toString(), e); + throw new ServletException(e); + } + } + + /* + * (non-Java-doc) + * + * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest arg0, HttpServletResponse arg1) + */ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + response.setContentType("text/html"); + + PrintWriter out = response.getWriter(); + + out.println(); + out.println("

BigBank database initialization servlet !

"); + out.println(); + } + + public AccountDBInit() { + } + + public AccountDBInit(String dbDirectory, String dasConfigFile, Boolean deleteExisting) { + this.dbDirectory = dbDirectory; + this.dasConfigFile = dasConfigFile; + this.deleteExisting = deleteExisting; + } + + private Connection createConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException { + return createConnection(dbDirectory); + } + + private static Connection createConnection(final String location) throws InstantiationException, IllegalAccessException, ClassNotFoundException, + SQLException { + Connection conn; + Class.forName(driver).newInstance(); + Properties props = new Properties(); + conn = DriverManager.getConnection(protocol + location + ";create=true", props); + + conn.setAutoCommit(false); + return conn; + } + + public static void createDB(final String location) throws Exception { + Connection conn = null; + AccountDataServiceDASImpl.dbDirectory = location; + AccountLoggerServiceImpl.dbDirectory = location; // TODO get rid of this (isilval) + Exception processessingException = null; + try { + conn = createConnection(location); + + creatTables(conn); + + int id = createCustomer(conn, "Test", "User", "304 Fox Trot ln, Apex, NC", "test@das.org", "test", "password"); + createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 123.43F); + createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 23.12F); + createStockPurchase(conn, id, "IBM", 33, 66.20F, "2005-11-23 13:22:02"); + createStockPurchase(conn, id, "DELL", 13, 12.74F, "2003-01-03 11:04:03"); + createStockPurchase(conn, id, "LU", 7, 2.74F, "2003-01-04 16:04:03"); + createStockPurchase(conn, id, "IBM", 22, 81.43F, "2004-02-03 13:04:33"); + + id = createCustomer(conn, "test2", "demo2", "Pleasant Plains Rd, ViewMount, CO", "test2@das.org", "test2", "password"); + createAccount(conn, id, AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_SAVINGS, 924.40F); + createAccount(conn, id, AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + id, AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS, 33.26F); + createStockPurchase(conn, id, "FOO", 3, 6.20F, "2000-09-11 09:11:01"); + + conn.commit(); + + } catch (org.apache.derby.impl.jdbc.EmbedSQLException e) { + if (conn != null && !conn.isClosed()) { + conn.rollback(); + } + if (e.getErrorCode() == 20000 && "X0Y32".equalsIgnoreCase(e.getSQLState()) && -1 != e.getMessage().indexOf("already exists")) { + // this is ok the database is there. + + } else { + + e.printStackTrace(); + processessingException = e; + throw e; + } + } finally { + try { + if (null != conn && !conn.isClosed()) { + + conn.close(); + } + conn = null; + } catch (Exception e) { + e.printStackTrace(); + if (null != processessingException) { + throw e; + } + } + } + + } + + protected static void creatTables(Connection conn) throws Exception { + Statement s = conn.createStatement(); + + s + .execute("create table customers(firstName varchar(80) NOT NULL, lastName varchar(80), address varchar(180),email varchar(40),loginID varchar(80) NOT NULL UNIQUE, password varchar(80), id int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY)"); + + s.execute("create table accounts(id int NOT NULL, accountNumber varchar(80) NOT NULL UNIQUE, accountType varchar(80), balance real )"); + + s + .execute("create table stocks(id int NOT NULL, Symbol varchar(8) NOT NULL, quantity int NOT NULL, purchasePrice real NOT NULL, purchaseDate TIMESTAMP, purchaseLotNumber int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY )"); + + s + .execute("create table acctLog (logSeqNo int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY, id int NOT NULL, accountNumber varchar(80) NOT NULL, actionType varchar(32) NOT NULL, amount real )"); + + s + .execute("create table stockLog (logSeqNo int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY, id int NOT NULL, Symbol varchar(8) NOT NULL, quantity int NOT NULL, actionType varchar(32) NOT NULL, purchaseLotNumber int NOT NULL )"); + + s.close(); + } + + protected static int createCustomer(Connection conn, final String firstName, final String lastName, final String address, final String email, + final String logonID, final String password) throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into customers (firstName,lastName,address,email, loginID, password ) " + "values ('" + firstName + "', '" + lastName + + "', '" + address + "', '" + email + "', '" + logonID + "', '" + password + "')"); + + ResultSet rs = s.executeQuery("SELECT loginID, id FROM customers where loginID='" + logonID + "'"); + if (!rs.next()) { + throw new Exception("Wrong number of rows"); + } + int id = rs.getInt(2); + s.close(); + + return id; + } + + protected static void createAccount(Connection conn, int customerID, final String accountNumber, final String accountType, final float balance) + throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into accounts (id,accountNumber, accountType, balance ) " + "values (" + customerID + ", '" + accountNumber + "', '" + + accountType + "', " + balance + ")"); + + s.close(); + } + + protected InputStream createConfigStream() { + InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml"); + return mapping; + } + + protected static void createStockPurchase(Connection conn, int customerID, final String stockSymbol, final int quantity, + final float purchasePrice, String purchaseDate) throws SQLException, Exception { + Statement s = conn.createStatement(); + + s.execute("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate ) values (" + customerID + ", '" + stockSymbol + "', " + + quantity + ", " + purchasePrice + ", '" + purchaseDate + "')"); + + s.close(); + + } + + protected static void registerTypes() { + SDOUtil.registerStaticTypes(AccountFactory.class); + // TODO remove + SDOUtil.registerStaticTypes(ConfigFactory.class); + + } + + public void testWithdrawThroughDAS(withdraw wd) throws Exception { + + Connection conn = createConnection(); + DAS das = DAS.FACTORY.createDAS(createConfigStream(), conn); + Command select = das.getCommand("get account"); + + select.setParameter(1, wd.getAccountNumber()); + + DataObject root = select.executeQuery(); + + Collection accounts = root.getList("AccountSummary"); + AccountSummary account = (AccountSummary) accounts.iterator().next(); + float newbalance = account.getBalance() - wd.getAmount(); + account.setBalance(newbalance); + // update department set companyid = ? where department.name = ? + + Command update = das.getCommand("update balance"); + update.setParameter(1, new Float(newbalance)); + update.setParameter(2, wd.getAccountNumber()); + + update.execute(); + conn.close(); + } + + protected void testStrockPurchaseThroughDAS(purchaseStock sp) throws InstantiationException, IllegalAccessException, ClassNotFoundException, + SQLException { + + DAS das = DAS.FACTORY.createDAS(createConfigStream(), createConnection()); + Command read = das.getCommand("all stocks"); + + DataObject root = read.executeQuery(); + + // Create a new stockPurchase + DataObject stockPurchase = root.createDataObject("StockSummary"); + stockPurchase.set("id", new Integer(sp.getId())); + stockPurchase.set("symbol", sp.getStock().getSymbol()); + stockPurchase.set("quantity", new Integer(sp.getStock().getQuantity())); + stockPurchase.set("purchasePrice", new Float(11.00)); + // String type = stockPurchase.getType().getProperty("purchaseDate").getType().toString(); + stockPurchase.setDate("purchaseDate", new Date()); + + das.applyChanges(root); + } + + public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final String logonID) throws Exception { + InputStream mapping = createConfigStream(); + Connection conn = createConnection(); + DAS das = DAS.FACTORY.createDAS(mapping, conn); + Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = ?"); + + select.setParameter(1, logonID); + + DataObject root = select.executeQuery(); + conn.close(); + + Collection customers = root.getList("CustomerProfileData"); + CustomerProfileData customerProfileData = (CustomerProfileData) customers.iterator().next(); + System.out.println(customerProfileData); + System.out.flush(); + return customerProfileData; + + } + + protected void readDBstdout(PrintStream stream) throws Exception { + Connection conn = null; + try { + conn = createConnection(dbDirectory); + Statement s = conn.createStatement(); + ResultSet rs = s.executeQuery("SELECT firstName, lastName, loginID, password, id FROM customers ORDER BY lastName"); + while (rs.next()) { + stream.print(rs.getString(1)); + stream.print(" "); + stream.print(rs.getString(2)); + stream.print(" "); + stream.print(rs.getString(3)); + stream.print(" "); + stream.print(rs.getString(4)); + stream.print(" "); + stream.print(rs.getString(5)); + stream.println(); + int id = rs.getInt(5); + Statement s1 = conn.createStatement(); + ResultSet rs1 = s1.executeQuery("SELECT accountNumber, accountType, balance FROM accounts where id=" + id); + stream.println("====Customers accounts"); + while (rs1.next()) { + stream.print("\t"); + stream.print(rs1.getString(1)); + stream.print(" "); + stream.print(rs1.getString(2)); + stream.print(" "); + stream.print(rs1.getString(3)); + stream.println(); + } + rs1.close(); + rs1 = s1.executeQuery("SELECT symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id=" + id); + stream.println("====Customers Stocks"); + while (rs1.next()) { + stream.print("\t"); + stream.print(rs1.getString(1)); + stream.print(" "); + stream.print(rs1.getString(2)); + stream.print(" "); + stream.print(rs1.getString(3)); + stream.print(" "); + stream.print(rs1.getString(4)); + stream.print(" "); + stream.print(rs1.getString(5)); + stream.println(); + } + s1.close(); + stream.println(); + + } + s.close(); + conn.commit(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + if (conn != null) { + conn.close(); + } + conn = null; + } + + } + + public static class MyDateConverter implements Converter { + + private static final DateFormat tsformat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); + + public Object getPropertyValue(Object columnData) { + + try { + return tsformat.parse(columnData.toString()); + } catch (ParseException e) { + + e.printStackTrace(); + throw new IllegalArgumentException(e); + } + + } + + public Object getColumnValue(Object propertyData) { + + if (propertyData instanceof Date) { + return tsformat.format(propertyData); + } else { + throw new IllegalArgumentException(); + } + + } + + } + + /** + * @param args + */ + public static void main(String[] args) throws Exception { + registerTypes(); + String dbDirectory = null; // "c:/derbydbtest/foo"; + String dasConfigFile = null; + Boolean deleteExisting = false; + for (String x : args) { + if ("-d".equals(x)) { + deleteExisting = true; + } + if (x.startsWith("-db:")) { + dbDirectory = x.substring("-db:".length()); + } + if (x.startsWith("-config:")) { + dasConfigFile = x.substring("-config:".length()); + ; + } + + } + AccountDBInit accountDBInit = new AccountDBInit(dbDirectory, dasConfigFile, deleteExisting); + + createDB(dbDirectory); + + accountDBInit.readDBstdout(System.out); + + // Test withdrawl + withdraw wd = AccountFactory.INSTANCE.createwithdraw(); + wd.setAccountNumber("134-43-3942"); + wd.setAmount(1.00F); + accountDBInit.testWithdrawThroughDAS(wd); + + accountDBInit.readDBstdout(System.out); + + // test stock purchase. + purchaseStock sp = AccountFactory.INSTANCE.createpurchaseStock(); + StockSummary stock = AccountFactory.INSTANCE.createStockSummary(); + stock.setSymbol("GOOG"); + stock.setQuantity(10); + stock.setPurchasePrice(25.00F); + sp.setId(1); + sp.setStock(stock); + + accountDBInit.testStrockPurchaseThroughDAS(sp); + + accountDBInit.readDBstdout(System.out); + + System.out.flush(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java new file mode 100644 index 0000000000..2360344cd1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerDataServiceImpl.java @@ -0,0 +1,129 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountlogger; + +import java.rmi.RemoteException; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import bigbank.account.services.accountdata.AccountDataService; +import bigbank.account.services.accountdata.CustomerIdService; + +import com.bigbank.account.AccountLog; +import com.bigbank.account.AccountReport; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +/** + * This class implements the Account Data Logger service component. + */ +@Service(AccountDataService.class) +public class AccountLoggerDataServiceImpl implements AccountDataService { + + private CustomerIdService accountDataService; // TODO fix this! + + @Reference + public void setAccountDataService(CustomerIdService accountDataService) { + this.accountDataService = accountDataService; + } + + private AccountLoggerService accountLoggerService; + + @Reference + public void setAccountLoggerService(AccountLoggerService accountLoggerService) { + this.accountLoggerService = accountLoggerService; + } + + public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException { + accountLoggerService.logPurchaseStock(id, stock); + + return accountDataService.purchaseStock(id, stock); + } + + public CustomerProfileData getCustomerProfile(String logonID) throws RemoteException { + + return accountDataService.getCustomerProfile(logonID); + } + + public float deposit(String account, float amount) throws RemoteException { + try { + if (!(accountDataService instanceof CustomerIdService)) { + throw new RemoteException("Can't use data service as customer id service"); + } + int id = accountDataService.getCustomerIdByAccount(account); + // int id = accountDataService.getCustomerIdByAccount(account); + accountLoggerService.logDeposit(id, account, amount); + + return accountDataService.deposit(account, amount); + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createChecking) + throws RemoteException { + + return accountDataService.createAccount(customerProfile, createSavings, createChecking); + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + int id = accountDataService.getCustomerIdByPurchaseLotNumber(purchaseLotNumber); + StockSummary ss = accountDataService.sellStock(purchaseLotNumber, quantity); + if (ss != null) { + if (!(accountDataService instanceof CustomerIdService)) { + throw new RemoteException("Can't use data service as customer id service"); + } + accountLoggerService.logSellStock(id, ss, quantity); + } + return ss; + } catch (RemoteException e) { + e.printStackTrace(); + throw e; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass() + " " + e.getMessage(), e); + } + } + + public float withdraw(String account, float amount) throws RemoteException { + if (!(accountDataService instanceof CustomerIdService)) { + throw new RemoteException("Can't use data service as customer id service"); + } + int id = accountDataService.getCustomerIdByAccount(account); + // int id = accountDataService.getCustomerIdByAccount(account); + accountLoggerService.logWithdrawal(id, account, amount); + + return accountDataService.withdraw(account, amount); + } + + public AccountReport getAccountReport(final int customerID) throws RemoteException { + + return accountDataService.getAccountReport(customerID); + } + + public AccountLog getAccountLog(final int customerID) throws RemoteException { + return accountLoggerService.getAccountLog(customerID); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.java new file mode 100644 index 0000000000..b9b2821d38 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerService.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 bigbank.account.services.accountlogger; + +import java.rmi.RemoteException; + +import org.osoa.sca.annotations.OneWay; + +import com.bigbank.account.AccountLog; +import com.bigbank.account.StockSummary; + +/** + * This is the business interface of the Account Logger service component. + */ +public interface AccountLoggerService { + + @OneWay + public void logDeposit(int id, String account, float amount) throws RemoteException; + + @OneWay + public void logWithdrawal(int id, String account, float amount) throws RemoteException; + + @OneWay + public void logPurchaseStock(int id, StockSummary stock) throws RemoteException; + + @OneWay + public void logSellStock(int id, StockSummary stock, int quantity) throws RemoteException; + + public AccountLog getAccountLog(int id) throws RemoteException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java new file mode 100644 index 0000000000..8919aad311 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java @@ -0,0 +1,216 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.accountlogger; + +import java.io.InputStream; +import java.rmi.RemoteException; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Properties; + +import org.apache.tuscany.das.rdb.Command; +import org.apache.tuscany.das.rdb.DAS; +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountLog; +import com.bigbank.account.StockSummary; +import commonj.sdo.DataObject; + +/** + * This class implements the Account Logger service component. + */ +@Service(AccountLoggerService.class) +public class AccountLoggerServiceImpl implements AccountLoggerService { + + public static final String ACCT_ACTION_TYPE_DEPOSIT = "deposit"; + + public static final String ACCT_ACTION_TYPE_WITHDRAW = "withdraw"; + + public static final String STOCK_ACTION_TYPE_PURCHASE = "purchase"; + + public static final String STOCK_ACTION_TYPE_SELL = "sell"; + + static public String dbDirectory = null; + + protected static final String driver = "org.apache.derby.jdbc.EmbeddedDriver"; + + protected static final String protocol = "jdbc:derby:"; + + public void logDeposit(int id, String account, float amount) throws RemoteException { + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)"); + insert.setParameter(1, new Integer(id)); + insert.setParameter(2, account); + insert.setParameter(3, ACCT_ACTION_TYPE_DEPOSIT); + insert.setParameter(4, new Float(amount)); + + insert.execute(); + /* + * performLog("insert into acctLog (id, accountNumber, actionType, amount) values (" + id + ", '" + account + "', '" + + * ACCT_ACTION_TYPE_DEPOSIT + "', " + amount + ")"); + */ + } + + public void logWithdrawal(int id, String account, float amount) throws RemoteException { + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)"); + insert.setParameter(1, new Integer(id)); + insert.setParameter(2, account); + insert.setParameter(3, ACCT_ACTION_TYPE_WITHDRAW); + insert.setParameter(4, new Float(amount)); + + insert.execute(); + /* + * performLog("insert into acctLog (id ,accountNumber, actionType, amount) values (" + id + ", '" + account + "', '" + + * ACCT_ACTION_TYPE_WITHDRAW + "', " + amount + ")"); + */ + } + + public void logPurchaseStock(int id, StockSummary stock) throws RemoteException { + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)"); + insert.setParameter(1, new Integer(id)); + insert.setParameter(2, stock.getSymbol()); + insert.setParameter(3, new Integer(stock.getQuantity())); + insert.setParameter(4, STOCK_ACTION_TYPE_PURCHASE); + insert.setParameter(5, new Integer(stock.getPurchaseLotNumber())); + + insert.execute(); + /* + * performLog("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (" + id + ", '" + stock.getSymbol() + "', " + + * stock.getQuantity() + ", '" + STOCK_ACTION_TYPE_PURCHASE + ", " + stock.getPurchaseLotNumber() + ")"); + */ + } + + public void logSellStock(int id, StockSummary stock, int quantity) throws RemoteException { + + String symbol = ((stock.getSymbol() != null) ? stock.getSymbol() : "null"); + DAS das = DAS.FACTORY.createDAS(getConnection()); + Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)"); + insert.setParameter(1, new Integer(id)); + insert.setParameter(2, symbol); + insert.setParameter(3, new Integer(quantity)); + insert.setParameter(4, STOCK_ACTION_TYPE_SELL); + insert.setParameter(5, new Integer(stock.getPurchaseLotNumber())); + + insert.execute(); + /* + * performLog("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (" + id + ", '" + stock.getSymbol() + "', " + + * quantity + ", '" + STOCK_ACTION_TYPE_SELL + ", " + stock.getPurchaseLotNumber() + ")"); + */ + } + + private void performLog(String toLog) throws RemoteException { + + try { + Connection conn = getConnection(); + + Statement s = conn.createStatement(); + + s.execute(toLog); + + conn.commit(); + + System.out.println("SN id acctNo action amount"); + ResultSet rs = s.executeQuery("select * from acctLog"); + while (rs.next()) { + System.out.println(rs.getInt("logSeqNo") + " " + rs.getInt("id") + " " + rs.getString("accountNumber") + " " + + rs.getString("actionType") + " " + rs.getFloat("amount")); + } + + conn.commit(); + + System.out.println("SN Symbol qty action plot#"); + rs = s.executeQuery("select * from stockLog"); + while (rs.next()) { + System.out.println(rs.getInt("logSeqNo") + " " + rs.getString("Symbol") + " " + rs.getInt("quantity") + " " + + rs.getString("actionType") + " " + rs.getInt("purchaseLotNumber")); + } + + conn.commit(); + + s.close(); + + conn.close(); + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass().getName(), e); + } + + System.out.println("Logged " + toLog); + } + + protected Connection getConnection() throws RemoteException { + try { + Connection conn; + Class.forName(driver).newInstance(); + Properties props = new Properties(); + // props.put("user", "tuscany"); + // props.put("password", "tuscany"); + conn = DriverManager.getConnection(protocol + dbDirectory + ";create=true", props); + + conn.setAutoCommit(false); + return conn; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass().getName(), e); + } + } + + public AccountLog getAccountLog(final int customerID) throws RemoteException { + + try { + final AccountFactory accountFactory = AccountFactory.INSTANCE; + final AccountLog accountLog = accountFactory.createAccountLog(); + InputStream mapping = createConfigStream(); + + Connection conn = getConnection(); + DAS das = DAS.FACTORY.createDAS(mapping, conn); + Command select = das.createCommand("SELECT logSeqNo, accountNumber, actionType, amount FROM acctLog where id = ?"); + + select.setParameter(1, customerID); + + DataObject root = select.executeQuery(); + accountLog.getAccountLogEntries().addAll(root.getList("AccountLogEntry")); + + select = das.createCommand("SELECT logSeqNo, Symbol, quantity, actionType, purchaseLotNumber FROM stockLog where id = ?"); + select.setParameter(1, customerID); + root = select.executeQuery(); + accountLog.getStockLogEntries().addAll(root.getList("StockLogEntry")); + + conn.close(); + + return accountLog; + } catch (Exception e) { + if (e instanceof RemoteException) { + throw (RemoteException) e; + } + throw new RemoteException("getAccountLog failed. customerID ('" + customerID + "')" + e.getClass().getName() + "'. " + e.getMessage(), e); + } + } + + protected InputStream createConfigStream() { + InputStream mapping = getClass().getClassLoader().getResourceAsStream("DasAccountConfiguration.xml"); + return mapping; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java new file mode 100644 index 0000000000..c7498f093d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuote.java @@ -0,0 +1,228 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.stockquote; + +public class StockQuote { + + private String companyName; + + private String symbol; + + private String stockQuote; + + private String lastUpdated; + + private String change; + + private String openPrice; + + private String dayHighPrice; + + private String dayLowPrice; + + private String volume; + + private String marketCap; + + private String yearRange; + + private String exDividendDate; + + private String dividendYield; + + private String dividendPerShare; + + /** + * + * + * @generated + */ + protected StockQuote() { + super(); + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String newCompanyName) { + companyName = newCompanyName; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String newStockTicker) { + symbol = newStockTicker; + } + + public String getStockQuote() { + return stockQuote; + } + + public void setStockQuote(String newStockQuote) { + stockQuote = newStockQuote; + } + + public String getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(String newLastUpdated) { + lastUpdated = newLastUpdated; + } + + public String getChange() { + return change; + } + + public void setChange(String newChange) { + change = newChange; + } + + public String getOpenPrice() { + return openPrice; + } + + public void setOpenPrice(String newOpenPrice) { + openPrice = newOpenPrice; + } + + public String getDayHighPrice() { + return dayHighPrice; + } + + public void setDayHighPrice(String newDayHighPrice) { + dayHighPrice = newDayHighPrice; + } + + public String getDayLowPrice() { + return dayLowPrice; + } + + public void setDayLowPrice(String newDayLowPrice) { + dayLowPrice = newDayLowPrice; + } + + public String getVolume() { + return volume; + } + + public void setVolume(String newVolume) { + volume = newVolume; + } + + public String getMarketCap() { + return marketCap; + } + + public void setMarketCap(String newMarketCap) { + marketCap = newMarketCap; + } + + public String getYearRange() { + return yearRange; + } + + public void setYearRange(String newYearRange) { + yearRange = newYearRange; + } + + public String getExDividendDate() { + return exDividendDate; + } + + public void setExDividendDate(String newExDividendDate) { + exDividendDate = newExDividendDate; + } + + public String getDividendYield() { + return dividendYield; + } + + public void setDividendYield(String newDividendYield) { + dividendYield = newDividendYield; + } + + public String getDividendPerShare() { + return dividendPerShare; + } + + public void setDividendPerShare(String newDividendPerShare) { + dividendPerShare = newDividendPerShare; + } + + @Override + public String toString() { + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (companyName: "); + result.append(companyName); + result.append(", symbol: "); + result.append(symbol); + result.append(", stockQuote: "); + result.append(stockQuote); + result.append(", lastUpdated: "); + result.append(lastUpdated); + result.append(", change: "); + result.append(change); + result.append(", openPrice: "); + result.append(openPrice); + result.append(", dayHighPrice: "); + result.append(dayHighPrice); + result.append(", dayLowPrice: "); + result.append(dayLowPrice); + result.append(", volume: "); + result.append(volume); + result.append(", marketCap: "); + result.append(marketCap); + result.append(", yearRange: "); + result.append(yearRange); + result.append(", exDividendDate: "); + result.append(exDividendDate); + result.append(", dividendYield: "); + result.append(dividendYield); + result.append(", dividendPerShare: "); + result.append(dividendPerShare); + result.append(')'); + return result.toString(); + } + + @Override + public StockQuote clone() { + StockQuote ret = new StockQuote(); + ret.companyName = companyName; + ret.symbol = symbol; + ret.stockQuote = stockQuote; + ret.lastUpdated = lastUpdated; + ret.change = change; + ret.openPrice = openPrice; + ret.dayHighPrice = dayHighPrice; + ret.dayLowPrice = dayLowPrice; + ret.volume = volume; + ret.marketCap = marketCap; + ret.yearRange = yearRange; + ret.exDividendDate = exDividendDate; + ret.dividendYield = dividendYield; + ret.dividendPerShare = dividendPerShare; + return ret; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..9d5c243f9a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteService.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 bigbank.account.services.stockquote; + +import java.rmi.RemoteException; +import java.util.Map; + +/** + * This is the business interface of the HelloWorld service component. + */ +public interface StockQuoteService { + + public Map getQuotes(String[] symbols) throws RemoteException; + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.java new file mode 100644 index 0000000000..b0c31d4d81 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteServiceImpl.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 bigbank.account.services.stockquote; + +import java.rmi.RemoteException; +import java.util.Hashtable; +import java.util.Map; +import java.util.Random; + +/* Mock StockQuoteService */ + +public class StockQuoteServiceImpl implements StockQuoteService { + + static Random rn = new Random(); + + static Hashtable stocks = new Hashtable(); + + public synchronized Map getQuotes(String[] symbols) throws RemoteException { + Map ret = new Hashtable(); + for (String sym : symbols) { + sym = sym.toUpperCase(); + if (!ret.containsKey(sym)) { + StockQuote sq = stocks.get(sym); + if (sq == null) { + sq = new StockQuote(); + stocks.put(sym, sq); + sq.setSymbol(sym); + sq.setCompanyName(sym + " INC"); + float val = rn.nextFloat() * 97.0F + 3.0F; + sq.setStockQuote(val + ""); + sq.setDayHighPrice(val + ""); + sq.setDayLowPrice(val + ""); + sq.setOpenPrice(val + ""); + } else { + float diff = (rn.nextFloat() * 2.0F) - 1; + float newval = new Float(sq.getStockQuote()) + diff; // auto boxing cool. + sq.setStockQuote(newval + ""); + float dh = Math.max(newval, new Float(sq.getDayHighPrice())); + sq.setDayHighPrice(dh + ""); + float dl = Math.min(newval, new Float(sq.getDayLowPrice())); + sq.setDayLowPrice(dl + ""); + + } + ret.put(sym, sq.clone()); + } + + } + + return ret; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java new file mode 100644 index 0000000000..053f9d7f16 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/java/bigbank/account/services/stockquote/StockQuoteWebservicexServiceImpl.java @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account.services.stockquote; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.rmi.RemoteException; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Map; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; + +import net.x.webservice.StockQuoteSoap; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements the Stock quote service component. + */ +@Service(StockQuoteService.class) +@Scope("COMPOSITE") +public class StockQuoteWebservicexServiceImpl implements StockQuoteService { + + @Reference + public StockQuoteSoap stockQuoteService = null; // Injected by the SCA container. + + /** + * @throws RemoteException + * @see bigbank.account.services.stockquote.StockQuoteService#getQuotes(String[]) + */ + public Map getQuotes(final String[] symbols) throws RemoteException { + try { + assert null != stockQuoteService : "stockQuoteService was not set by the SCA runtime!"; + StringBuilder sb = new StringBuilder(5 * symbols.length); + for (String sym : symbols) { + if (sb.length() != 0) { + sb.append(' '); + } + sb.append(sym); + } + String stockdata = stockQuoteService.GetQuote(sb.toString()); + + InputStream in = new ByteArrayInputStream(stockdata.getBytes()); + XMLInputFactory factory = XMLInputFactory.newInstance(); + XMLStreamReader parser = factory.createXMLStreamReader(in); + ArrayList listQuotes = new ArrayList(); + Hashtable listQuoteHT = new Hashtable(); + MapStock currentStock = null; + StringBuilder currentText = new StringBuilder(100); + for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) { + String lname; + switch (event) { + case XMLStreamConstants.START_ELEMENT: + if (parser.getLocalName() == "Stock") { + + currentStock = new MapStock(); + listQuotes.add(currentStock); + } + break; + case XMLStreamConstants.END_ELEMENT: + lname = parser.getLocalName(); + String mname = "set" + lname; + try { + Method setter = MapStock.class.getMethod(mname, new Class[] { String.class }); + if (setter != null) { + setter.invoke(currentStock, currentText.toString()); + if (lname.equals("Symbol")) { + listQuoteHT.put(currentText.toString(), currentStock); + + } + } + } catch (NoSuchMethodException e) { + + } + // System.err.println(parser.getLocalName() + ":" + currentText.toString()); + currentText.setLength(0); + break; + case XMLStreamConstants.CHARACTERS: + // System.out.print(parser.getText()); + currentText.append(parser.getText()); + break; + case XMLStreamConstants.CDATA: + // System.out.print(parser.getText()); + currentText.append(parser.getText()); + break; + } // end switch + } // end while + parser.close(); + + return listQuoteHT; + } catch (Exception e) { + e.printStackTrace(); + throw new RemoteException(e.getClass().getName() + e.getMessage(), e); + } + } + + public static class MapStock extends StockQuote { + + public void setLast(String val) { + super.setStockQuote(val); + } + + public void setDate(String val) { + }; + + public void setTime(String val) { + }; + + public void setHigh(String val) { + super.setDayHighPrice(val); + } + + public void setLow(String val) { + super.setDayLowPrice(val); + } + + public void setOpen(String val) { + super.setOpenPrice(val); + } + + public void setMktCap(String val) { + super.setMarketCap(val); + } + + public void setName(String val) { + super.setCompanyName(val); + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/DasAccountConfiguration.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/DasAccountConfiguration.xml new file mode 100644 index 0000000000..ed1553eb40 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/DasAccountConfiguration.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + + + + +
+ + + + + + + + +
+ + + + + + + + + + +
+ + + + + + + + + + + +
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..5e8ced28e0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,467 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl new file mode 100644 index 0000000000..16c980a30e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/resources/wsdl/stockquotes.webservicex.wsdl @@ -0,0 +1,136 @@ + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Get Stock quote for a company Symbol + + + + + + + Get Stock quote for a company Symbol + + + + + + + Get Stock quote for a company Symbol + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/default.scdl new file mode 100644 index 0000000000..7c83a1a648 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/default.scdl @@ -0,0 +1,80 @@ + + + + + + + + + + + + + AccountServiceComponent + + + + USD + + + + + AccountLoggerDataServiceComponent + StockQuoteServiceComponent + + + + + AccountDataServiceComponent + AccountLoggerServiceComponent + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..509e5a052d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,70 @@ + + + + + + + Tuscany Bigbank Account sample + + + + + + + tuscany.online + false + + + + + org.apache.tuscany.runtime.webapp.TuscanyContextListener + + + + TuscanyServlet + Tuscany Servlet + org.apache.tuscany.runtime.webapp.TuscanyServlet + + + + TuscanyServlet + /* + + + + + AccountDBInit + bigbank.account.services.accountdb.AccountDBInit + 2 + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/test/java/bigbank/account/client/AccountClient.java new file mode 100644 index 0000000000..28f9e762f0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/account/src/test/java/bigbank/account/client/AccountClient.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 bigbank.account.client; + +import java.util.Iterator; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.AccountSummary; + +public class AccountClient { + + public void start() { + } + + public void stop() { + } + + public static void main(String[] args) throws Exception { + + CompositeContext context = CurrentCompositeContext.getContext(); + + AccountService accountService = context.locateService(AccountService.class, "AccountServiceComponent"); + + AccountReport accountReport = accountService.getAccountReport(12345); + + for (Iterator i = accountReport.getAccountSummaries().iterator(); i.hasNext();) { + AccountSummary accountSummary = (AccountSummary) i.next(); + + System.out.println(accountSummary.getAccountNumber()); + System.out.println(accountSummary.getAccountType()); + System.out.println(accountSummary.getBalance()); + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/Show.Image.html b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/Show.Image.html new file mode 100644 index 0000000000..9b18679abf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/Show.Image.html @@ -0,0 +1,40 @@ + + + + + + +
+ +
+ + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountfiles.png b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountfiles.png new file mode 100644 index 0000000000..9fc46488a0 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountfiles.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountmodule.png b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountmodule.png new file mode 100644 index 0000000000..d4209a01e3 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/accountmodule.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/modualoverview.png b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/modualoverview.png new file mode 100644 index 0000000000..7e6d7ba25e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/modualoverview.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientfiles.png b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientfiles.png new file mode 100644 index 0000000000..b951ed2e5e Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientfiles.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientmodule.png b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientmodule.png new file mode 100644 index 0000000000..dfd3a34bfb Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/docs/webclientmodule.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/pom.xml new file mode 100644 index 0000000000..b69e5dd06a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/pom.xml @@ -0,0 +1,44 @@ + + + + + org.apache.tuscany.sampleapps + tuscany-sca + 0.1-integration-incubating-SNAPSHOT + ../../pom.xml + + 4.0.0 + org.apache.tuscany.samples.bigbank + bigbank-scenario + pom + Tuscany BigBank Scenario Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + account + webclient + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/readme.html b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/readme.html new file mode 100644 index 0000000000..b5e90bb08f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/readme.html @@ -0,0 +1,894 @@ + + + + + + + + + Tuscany BigBank Sample Application + + + + + + +

Tuscany BigBank Sample Application

+ +

Overview

+ +

The Tuscany BigBank sample application  shows using + the Tuscany SCA runtime to build a  financial application. + There are two modules: webclient provides the front-end user + interface and account provides the back-end business services. + These are deployed as separate web applications

+ +

Location

+

This sample is located in the  + samples\applications\bigbank directory. There are two + subdirectories in that for the two modules account and webclient.

+ + +

Prerequisites

+ +

Obtain the following prerequisites and install according to + their documentation.

+ + + +

Building

+

This sample + can be built from the bigbank directory using Maven 2.0.4 with + the following command:

+

+  mvn
+

+ +

Setup

+

If you have enabled remote deployment in Tomcat by + adding the line:
+   <user username="admin" password="" + roles="manager"/>
+ into  <tomcat + dir>\conf\tomcat-users.xml  you can deploy the + WARs to Tomcat using the tomcat-maven-plugin:
+ mvn tomcat:deploy

+

Alternatively you can copy the WAR files to Tomcat's  + webapps directory.
+ + copy account\target\sample-bigbank-account.war <tomcat dir>\webapps
+ copy  + webclient\target\sample-bigbank-webclient.war <tomcat dir>\webapps
+

+ +

Running

+

Once you've started your web server, use your web + browser to view the following URL http://localhost:8080/sample-bigbank-webclient/
+ You can either use an already pre configured  account with + Login as test and + Password as password, or + you can  create a new account.
+ The demo is first configured to use a local mock stock quote + service that returns random stock data.  If you want to use + an actual stock quote provider follow these steps:

+ +
    +
  • Stop your server by issuing in the  <tomcat dir>\bin directory
  • + +
  • Issue shutdown + command to stop your web application server.
  • + +
  • Edit the account SCDL file <tomcat dir>\webapps\sample-bigbank-account\WEB-INF\default.scdl
  • + +
  • Change the SCDL wiring to remove the mock stock quote + service by commenting it out as follows:
    + <!--
    +     <component + name="StockQuoteServiceComponent">
    +         + <implementation.java + class="bigbank.account.services.stockquote.StockQuoteServiceImpl" + />
    +     </component>
    + -->
  • + +
  • Uncomment the real stockquote service section in lines 68 + to 80.
  • + +
  • Change to the directory  apache-tomcat-5.5.17\bin 
  • + +
  • issue startup +   command to start up the server in the + <tomcat dir>\bin + directory.
  • +
+

The sample should now be using the real stock quote + provider. 

+ +

Summary

This example illustrates using Tuscany runtime + in building a financial Web application using SCA programing + model.  The following key concepts are covered:

+ +
    +
  • Component implementations. that provide web + based  HTML user interface
  • + +
  • Component implementations that provide + local services in Java. Local services implement + internal application business logic such as tracking user state + and are not exposed remotely.
  • + +
  • Component implementations that have + configuration properties and service + references to other services
  • + +
  • Components that use and + configure the properties and + references of component implementations
  • + +
  • SCA Services to publish remotable services + via a Web Service binding.
  • + +
  • SCA References  to consume remotable + services via a Web Service binding
  • + +
  • Assembling implementation, components, entry points and + external service into composite components.
  • + +
  • Creating a module and all of its artifacts as part of a + web application to show a front-end access to SCA + services
  • + +
  • The use of Data Access services to persist and retrieve + Service Data Objects from Apache Derby.
  • + +
  • The use of  existing Web + services in  SCA.
  • +

BigBank sample provides the following user services: account + balance, making deposits and withdrawals  to purchase + and sell stock, and to view current stock value.
+ The sample is organized into two SCA modules: webclient and + account. The webclient module functionality is to provide user + information and obtain user input. The account module is used to + retrieve and store user information, account information, current + stock information and the purchasing and selling of stock. The + two modules interact via web services through SCA references and + services.

+
+ +
+ + + +
Webclient

+ + Webclient files
+ +

 

+ + + + + + + + + +
+ + + 
+ +
+ click to + enlarge +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Java + source files implementing SCA components and + interfaces.
+ AccountServiceComponentImpl.java Implements the account service.
AccountLoginServiceImpl.javaImplements the Login service.
LoginService.javaInterface for a services provided by a + login  service component.
ProfileService.javaInterface for a service provided by a profile + component.
ProfileServiceImpl.javaImplements the profile component.
SimpleLoginServiceImpl.javaA simple in memory login service.
+ Java + source files implementing Web HTML + interface.
AccountStatusTag.javaImplements a jsp tag that displays the + account information
StockStatusTag.javaImplements a jsp tag that displays the stock + information.
LoginBarrierTag.javaImplements a jsp tag that ensures the user is + logged in.
ServiceTag.javaPlaces an SCA service in the JSP page + context.
FormServlet.javaProcess user input and uses the + AccountService component.
LoginServlet.javaProcesses logging in and logout.
+ Files + that will be loaded as resources along + classpath.
AccountService.wsdlWSDL that  defines the account + service.
bigbank-tags.tldDefines the tag libs for the user + interface.
Files + located in WEB-INF directory.
default.scdlApplication's SCA SCDL file.
web.xmlApplication's web.xml file.
Generated + Files.
sdo sourceGenerated SDO. Created by tuscany-sdo-plugin + maven plugin.
wsdl2java-sourceGenerated SDO interface. Created by tuscany-plugin-wsdl2java + maven  plugin.
Build + files.
pom.xmlMaven build file.
+
+ +

 

+ +
Account

+ + Account module
+ +

 

+ + + + + + + + + +
+ + + 
+ +
+ click to + enlarge +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Java + source files implementing SCA components and + interfaces.
+ AccountServiceImpl.java Implements the account service + component.
AccountDataService.javaInterface defined for component implementing +  an account's data service.
AccountDataServiceDASImpl.javaA Data Access Service (DAS) implementation of + of the Account Data Service.
AccountDataServiceImpl.javaA Data Service implementation not using + DAS.
AccountDBInit.javaA utility to just create the database and it + table and fill in some initial data.
StockQuote.javaA class to hold the StockQuote + information.
StockQuoteService.javaInterface defined for a component + implementing a stock quote service.
StockQuoteServiceImpl.javaImplements a fake stock quote service.
StockQuoteWebservicexServiceImpl.javaImplements an actual stock quote + service.
+ Files + that will be loaded as resources along + classpath.
AccountService.wsdlWSDL that  defines the account + service
stockquotes.webservicex.wsdlActual stock quote service WSDL.
DasAccountConfiguration.xmlProvides any needed configuration info + including datasource properties, table + definitions,
Files + located in WEB-INF directory.
default.scdlApplication's SCA SCDL file.
web.xmlApplication's web.xml file.
Generated + Files.
sdo sourceGenerated SDO. Created by tuscany-sdo-plugin + maven plugin.
wsdl2java-sourceGenerated SDO interface. Created + by tuscany-plugin-wsdl2java + maven  plugin.
Build + files.
pom.xmlMaven build file.
+
+

+
+ + +
Pom.xml
+

The directions + for maven  how  to build the each module is located in + each module's directory in the pom.xml file.  The + application uses Java 1.5 and thus in the build  plugin + section needs the following compiler directives:

+             + <plugin>
+                 + <groupId>org.apache.maven.plugins</groupId>
+                 + <artifactId>maven-compiler-plugin</artifactId>
+                 + <configuration>
+                     + <source>1.5</source>
+ +                     + <target>1.5</target>
+ +                 + </configuration>
+             + </plugin>

+

Both webclient and account uses three maven + plugins: tuscany-sdo-plugintuscany-plugin-wsdl2java, + and tuscany-war-plugin. + The tuscany-sdo-plugin is provided by Tuscany 's SDO project + while the other two are provided by the Tuscany SCA project.

+

The tuscany-sdo-plugin +  references the WSDL's schema and generates all the files + located in target/sdo_source directory.  The application + uses these classes as a databinding instead of having to deal + directly with XML that  represents form as defined in the + WSDL's schema.

+

The tuscany-plugin-wsdl2java + plugin generates a Java interface in the target/wsdl2java-source + directory that is used to define the inteface (prottype) in the + wsdl.

+

The tuscany-war-plugin is + used to add both the Tuscany runtime and any Tuscany  + extensions required by the application in the war file.. Looking + at the pom.xml and search for  "tuscany-war-plugin" you'll find the + plugin.  Which extension you want loaded are specified in + the extensions section. The format + for this  closely follows Maven's artifact naming.  The + boolean loadExtensionDependencies + option if true will  resolve all dependencies for each + extension listed here and also include them in the war file. +  
+
+ +

Application

+ +
Web.xml

The web.xml + file in each module adds necessary "hooks" to initiate and + maintain the Tuscany SCA runtime in a web application host.
+  

+ + + + + + + + + + + + + + + + + + + + + +
+
+<listener>
+<listener-class>org.apache.tuscany.runtime.webapp.TuscanyContextListener</listener-class>
+</listener>
+
+
This class initializes the Tuscany runtime when the + applications is started and helps finalize the Tuscany + runtime when the application has ended.
+
+<servlet>
+<servlet-name>TuscanyServlet</servlet-name>
+<display-name>Tuscany Servlet</display-name>
+<servlet-class>org.apache.tuscany.runtime.webapp.TuscanyServlet</servlet-class>
+</servlet>
+
+
This class provides the web applications servlet + interface to SCA components.  The Axis websevices + binding extension requires this.
+
+<listener>
+<listener-class>org.apache.tuscany.runtime.webapp.TuscanySessionListener</listener-class>
+</listener>
+
+
This listener helps provide SCA session support .

+

The web application can be run in offline or online when + resolving dependencies required by the application or it's + required extensions. This is configured in the web.xml with the + context-param element with a parameter name tuscany.online. If  not + specified or set to true, dependencies are resolved by searching + the local war repository, the local Maven repository, and remote + repositories. If specified and set to false, the remote + repositories will not be searched.

+ +
SCDL
+

Each module's SCA + application SCDL is located in the web application  + WEB-INF/default.scdl file.  This is the default location, + but within the web.xml it is possible to override this with a + context-param element  with the name tuscany.applicationScdlPath. +  The Tuscany System SCDL can also be overridden with another + context-param element with the name tuscany.systemScdlPath.
+ The SCDL  used by the BigBank application is defined by + SCA Assembly Model V0.96 , SCA Client and Implementation Model for Java + (V0.95)  and the SCA Web Service bindings specifications.
+ There is one extension to SCDL used by BigBank that is specific + to Tuscany that is used by SDO databinding extension. +  The import.sdo element in the SCDL + specifies which  SDO factories to register the SDO types. +  In the case of BigBank the factory is the class generated + by the tuscany-sdo-plugin maven plugin. An + example of this follows:

+
+ <dbsdo:import.sdo xmlns:dbsdo="http://incubator.apache.org/tuscany/xmlns/databinding/sdo/1.0-incubator-M2"
+factory="com.bigbank.account.AccountFactory"/> 
+
+
+ +
Code

The Java code for the most part just implements the + Web interface and the SCA components necessary to implement the + business logic. The code uses Java 5.0 annotations as documented + by the SCA Client and Implementation Model for Java + (V0.95) specifications. The samples uses one annotation that + is an Tuscany extension that is used by the databinding framework + to identify that the components expect to SDO s for complex data + types. An example of this is seen in the AccountService interface + which has the @DataType(name="commonj.sdo.DataObject") + annotation.

+ +

RDB DAS

+ +

The Relational Database DAS (RDB DAS) is used in this sample to access relational data in terms + of SDOs. All the code pertaining to this usage is contained to two one files: + AccountDataServiceDASImpl.java and DasAccountConfiguration.xml. The java file provides code that + instantiates and invokes the DAS and the XML file provides RDB DAS configuration.

+ +

The sample demonstrates a few of the RDB DAS capabilities including:

+ +
    + +
  • reading a graph of SDOs based on a select query provided inline
  • +
  • reading a graph of SDOs based on a named select query defined in the config file
  • +
  • executing a named command to manually insert data
  • +
  • leveraging SDO Change Summary to by utilizing the DAS "applyChanges" method to flush graph modifications
  • +
  • utilizing the DAS column-converter framework
  • +
  • using the column/property name mapping (aliasing)
  • + +
+ +

This sample does not currently demonstrate a few other key DAS features including Object relationships, optimistic + concurrency control, and the use of convention over configuration. User level documentation for the RDB DAS can + be found in the RDBDAS User's Guide. +

+

This sample uses the RDB DAS as a utility. A future version of this sample will access the DAS as an SCA service. +

+ + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/pom.xml new file mode 100644 index 0000000000..40e146685a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/pom.xml @@ -0,0 +1,167 @@ + + + + + org.apache.tuscany.samples.bigbank + bigbank-scenario + 0.1-integration-incubating-SNAPSHOT + + 4.0.0 + sample-bigbank-webclient + war + Tuscany BigBank Web Client Module + BigBank Scenario Sample - Web Front-End Module + + + + org.apache.tuscany.sca.kernel + tuscany-api + ${scaKernelVersion} + compile + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.0-incubating + compile + + + + stax + stax-api + 1.0.1 + runtime + + + org.codehaus.woodstox + wstx-asl + 3.2.0 + runtime + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + compile + + + + org.apache.tuscany.sca.runtime.webapp + webapp-api + ${scaKernelVersion} + runtime + + + + + javax.servlet + servlet-api + 2.5 + provided + + + javax.servlet + jsp-api + 2.0 + provided + + + + junit + junit + 4.2 + test + + + + + ${artifactId} + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.0-incubating + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + true + true + true + + + generate + + + + + + org.apache.tuscany.sca.extensions.axis2.plugins + tuscany-plugin-wsdl2java + ${scaKernelVersion} + + + + ${basedir}/src/main/resources/wsdl/AccountService.wsdl + + + generate + + + + + + org.apache.tuscany.sca.runtime.webapp + tuscany-war-plugin + ${scaKernelVersion} + + + tuscany-war + + tuscany-war + + + + + + + false + + + + org.apache.tuscany.sca.services.databinding + databinding-sdo + ${scaKernelVersion} + + + org.apache.tuscany.sca.extensions.axis2 + tuscany-axis2 + ${scaKernelVersion} + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java new file mode 100644 index 0000000000..a0f98f14f3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/account/AccountServiceComponentImpl.java @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.services.account; + +import java.rmi.RemoteException; + +import org.osoa.sca.ServiceUnavailableException; +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountLog; +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +/** + */ +@Service(AccountService.class) +public class AccountServiceComponentImpl implements AccountService { + + private AccountService accountService; + + @Reference + public void setAccountService(AccountService accountService) { + this.accountService = accountService; + } + + /** + * + */ + public AccountServiceComponentImpl() { + super(); + } + + /** + * @see bigbank.account.services.account.AccountService#getAccountReport(java.lang.String) + */ + public AccountReport getAccountReport(int customerID) { + try { + return accountService.getAccountReport(customerID); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public StockSummary purchaseStock(int customerID, StockSummary stockSummary) throws RemoteException { + try { + return accountService.purchaseStock(customerID, stockSummary); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public CustomerProfileData getCustomerProfile(String param2) throws RemoteException { + try { + return accountService.getCustomerProfile(param2); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public float deposit(String account, float amount) throws RemoteException { + try { + return accountService.deposit(account, amount); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException { + try { + return accountService.sellStock(purchaseLotNumber, quantity); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public float withdraw(String account, float amount) throws RemoteException { + try { + return accountService.withdraw(account, amount); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + + public CustomerProfileData createAccount(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings) + throws RemoteException { + + return accountService.createAccount(customerProfile, createSavings, createCheckings); + } + + public AccountLog getAccountLog(int customerID) throws RemoteException { + try { + return accountService.getAccountLog(customerID); + } catch (Exception e) { + throw new ServiceUnavailableException(e); + } + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java new file mode 100644 index 0000000000..d6c40e8dda --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/AccountLoginServiceImpl.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.services.profile; + +import java.rmi.RemoteException; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; + +@Service(LoginService.class) +@Scope("COMPOSITE") +public class AccountLoginServiceImpl implements LoginService { + + public AccountService accountService; + + @Reference + public void setAccountService(AccountService accountService) { + this.accountService = accountService; + } + + public ProfileService profileService; + + @Reference + public void setProfileService(ProfileService profileService) { + this.profileService = profileService; + } + + public int login(String userName, String password) throws RemoteException { + + CustomerProfileData profileData = accountService.getCustomerProfile(userName); + + if (!password.equals(profileData.getPassword())) { + return INVALID_PASSWORD; + } + + profileService.setLoggedIn(true); + profileService.setFirstName(profileData.getFirstName()); + profileService.setLastName(profileData.getLastName()); + profileService.setId(profileData.getId()); + + return SUCCESS; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.java new file mode 100644 index 0000000000..c688df2597 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/LoginService.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 bigbank.webclient.services.profile; + +import java.rmi.RemoteException; + +import org.apache.tuscany.api.annotation.DataType; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface LoginService { + + static final int SUCCESS = 1; + + static final int INVALID_LOGIN = -1; + + static final int INVALID_PASSWORD = -2; + + int login(String userName, String password) throws RemoteException; +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.java new file mode 100644 index 0000000000..551d80c935 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileService.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 bigbank.webclient.services.profile; + +import org.apache.tuscany.api.annotation.DataType; +import org.osoa.sca.annotations.Remotable; + +@Remotable +public interface ProfileService { + + String getFirstName(); + + void setFirstName(String pName); + + String getLastName(); + + void setLastName(String pName); + + boolean isLoggedIn(); + + void setLoggedIn(boolean pStatus); + + int getId(); + + void setId(int pId); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.java new file mode 100644 index 0000000000..5385a7c3fc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/ProfileServiceImpl.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 bigbank.webclient.services.profile; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +@Service(ProfileService.class) +@Scope("SESSION") +public class ProfileServiceImpl implements ProfileService { + + private String firstName; + + public String getFirstName() { + return firstName; + } + + @Property + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + private String lastName; + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + private boolean loggedIn; + + public boolean isLoggedIn() { + return loggedIn; + } + + public void setLoggedIn(boolean status) { + loggedIn = status; + } + + private int id; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java new file mode 100644 index 0000000000..711c6ba0b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/services/profile/SimpleLoginServiceImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.services.profile; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Service; + +@Service(LoginService.class) +public class SimpleLoginServiceImpl implements LoginService { + + public ProfileService profileService; + + @Reference + public void setProfileService(ProfileService profileService) { + this.profileService = profileService; + } + + public int login(String userName, String password) { + + if (!"test".equals(userName)) { + return INVALID_LOGIN; + } + + if (!"password".equals(password)) { + return INVALID_PASSWORD; + } + + profileService.setLoggedIn(true); + profileService.setFirstName("John"); + profileService.setLastName("Doe"); + profileService.setId(12345); + + return SUCCESS; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java new file mode 100644 index 0000000000..08751bdc3d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountLogTag.java @@ -0,0 +1,120 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import bigbank.webclient.services.profile.ProfileService; + +import com.bigbank.account.AccountLog; +import com.bigbank.account.AccountService; + +public class AccountLogTag extends TagSupport { + + public AccountLogTag() { + super(); + } + + private String mAccountService; + + public String getAccountService() { + return mAccountService; + } + + public void setAccountService(String pAccountService) { + mAccountService = pAccountService; + } + + private String mProfileService; + + public String getProfileService() { + return mProfileService; + } + + public void setProfileService(String pProfileService) { + mProfileService = pProfileService; + } + + private String mId; + + @Override + public String getId() { + return mId; + } + + @Override + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + @Override + public int doStartTag() throws JspException { + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + + ProfileService profile = moduleContext.locateService(ProfileService.class, mProfileService); + + if (profile == null) { + throw new JspException("Profile [" + mProfileService + "] not found in current module context"); + } + + AccountService service = (AccountService) moduleContext.locateService(AccountService.class, mAccountService); + if (service == null) { + throw new JspException("Service [" + mAccountService + "] not found in current module context"); + } + List entries; + try { + AccountLog accountLog = service.getAccountLog(profile.getId()); + pageContext.setAttribute("StockLogEntries", accountLog.getStockLogEntries()); + entries = accountLog.getAccountLogEntries(); + } catch (Exception e) { + throw new JspException(e); + } + mIterator = entries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + @Override + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + return SKIP_BODY; + } + } + + @Override + public void release() { + super.release(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java new file mode 100644 index 0000000000..3733cc84dd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/AccountStatusTag.java @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import bigbank.webclient.services.profile.ProfileService; + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; + +/** + * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component + */ + +public class AccountStatusTag extends TagSupport { + + // ---------------------------------- + // Constructors + // ---------------------------------- + + public AccountStatusTag() { + super(); + } + + // ---------------------------------- + // Methods + // ---------------------------------- + + private String mAccountService; + + public String getAccountService() { + return mAccountService; + } + + public void setAccountService(String pAccountService) { + mAccountService = pAccountService; + } + + private String mProfileService; + + public String getProfileService() { + return mProfileService; + } + + public void setProfileService(String pProfileService) { + mProfileService = pProfileService; + } + + private String mId; + + @Override + public String getId() { + return mId; + } + + @Override + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + @Override + public int doStartTag() throws JspException { + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + + ProfileService profile = moduleContext.locateService(ProfileService.class, mProfileService); + + if (profile == null) { + throw new JspException("Profile [" + mProfileService + "] not found in current module context"); + } + + AccountService service = (AccountService) moduleContext.locateService(AccountService.class, mAccountService); + + if (service == null) { + throw new JspException("Service [" + mAccountService + "] not found in current module context"); + } + List summaries; + try { + AccountReport accountReport = service.getAccountReport(profile.getId()); + pageContext.setAttribute("StockSummaries", accountReport.getStockSummaries()); + summaries = accountReport.getAccountSummaries(); + } catch (Exception e) { + throw new JspException(e); + } + mIterator = summaries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + @Override + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + return SKIP_BODY; + } + } + + @Override + public void release() { + super.release(); + mId = null; + mIterator = null; + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java new file mode 100644 index 0000000000..ea2df8aa55 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockLogTag.java @@ -0,0 +1,81 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +public class StockLogTag extends TagSupport { + + public StockLogTag() { + super(); + } + + private String mId; + + @Override + public String getId() { + return mId; + } + + @Override + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + @Override + public int doStartTag() throws JspException { + + List entries = (List) pageContext.getAttribute("StockLogEntries"); + if (null == entries) { + return SKIP_BODY; + } + mIterator = entries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + @Override + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + pageContext.setAttribute("StockLogEntries", null); + return SKIP_BODY; + } + } + + @Override + public void release() { + pageContext.setAttribute("StockLogEntries", null); + super.release(); + mId = null; + mIterator = null; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java new file mode 100644 index 0000000000..b2c61193e7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/account/StockStatusTag.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.account; + +import java.util.Iterator; +import java.util.List; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +/** + * Retrieves and iterates over account summary information for the current profile by accessing the remotable account service component + */ + +public class StockStatusTag extends TagSupport { + + public StockStatusTag() { + super(); + } + + private String mId; + + @Override + public String getId() { + return mId; + } + + @Override + public void setId(String pId) { + mId = pId; + } + + private Iterator mIterator; + + @Override + public int doStartTag() throws JspException { + + List summaries = (List) pageContext.getAttribute("StockSummaries"); + if (null == summaries) { + return SKIP_BODY; + } + mIterator = summaries.iterator(); + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_INCLUDE; + } else { + return SKIP_BODY; + } + } + + @Override + public int doAfterBody() { + if (mIterator.hasNext()) { + pageContext.setAttribute(mId, mIterator.next()); + return EVAL_BODY_AGAIN; + } else { + pageContext.setAttribute("StockSummaries", null); + return SKIP_BODY; + } + } + + @Override + public void release() { + pageContext.setAttribute("StockSummaries", null); + super.release(); + mId = null; + mIterator = null; + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java new file mode 100644 index 0000000000..6c50595d0f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/LoginBarrierTag.java @@ -0,0 +1,101 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.sca; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import bigbank.webclient.services.profile.ProfileService; + +public class LoginBarrierTag extends TagSupport { + + public LoginBarrierTag() { + super(); + } + + private String mProfile; + + public String getProfile() { + return mProfile; + } + + public void setProfile(String pProfile) { + mProfile = pProfile; + } + + private String mUrl; + + public String getUrl() { + return mUrl; + } + + public void setUrl(String pUrl) { + mUrl = pUrl; + } + + int doPage = EVAL_PAGE; + + @Override + public int doStartTag() throws JspException { + if (mProfile == null || mProfile.length() < 1) { + throw new JspException("Invalid profile location specified"); + } + + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + + ProfileService profile = moduleContext.locateService(ProfileService.class, mProfile); + + if (profile == null) { + throw new JspException("Profile [" + mProfile + "] not found in current module context"); + } + + if (profile.isLoggedIn()) { + return EVAL_BODY_INCLUDE; + } else { + try { + doPage = SKIP_PAGE; + pageContext.forward(mUrl); + ((HttpServletResponse) (pageContext.getResponse())).sendRedirect("login.html"); + return SKIP_BODY; + } catch (ServletException e) { + throw new JspException("Unable to forward to [" + mUrl + "]"); + } catch (IOException e) { + throw new JspException("Unable to forward to [" + mUrl + "]"); + } + } + } + + @Override + public int doEndTag() throws JspException { + return doPage; + } + + @Override + public void release() { + super.release(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java new file mode 100644 index 0000000000..d1263377c2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/tags/sca/ServiceTag.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.tags.sca; + +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +/** + * Places an SCA service in the JSP page context, making it available to other tags corresponding to its id value. + */ + +public class ServiceTag extends TagSupport { + + // ---------------------------------- + // Constructors + // ---------------------------------- + + public ServiceTag() { + super(); + } + + // ---------------------------------- + // Methods + // ---------------------------------- + + private String mName; + + /** + * Returns the name of the SCA service to import into the page context. + */ + public String getName() { + return mName; + } + + /** + * Sets name of the SCA service to import into the page context. + */ + public void setName(String pName) { + mName = pName; + } + + private String mId; + + /** + * Returns the id of the service in the page context + */ + @Override + public String getId() { + return mId; + } + + /** + * Sets the id of the service for the page context + */ + + @Override + public void setId(String pId) { + mId = pId; + } + + @Override + public int doStartTag() throws JspException { + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + + Object service = moduleContext.locateService(Object.class, mName); + + if (service == null) { + throw new JspException("Service [" + mName + "] not found in current module context"); + } + if (mId == null) { + // if the Id name was not specified, default to the basic name of the + // service + mId = mName; + } + pageContext.setAttribute(mId, service); + return EVAL_BODY_INCLUDE; + } + + @Override + public int doEndTag() throws JspException { + return EVAL_PAGE; + } + + @Override + public void release() { + super.release(); + } +} \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java new file mode 100644 index 0000000000..3acdbee845 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/FormServlet.java @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.ui; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import bigbank.webclient.services.profile.ProfileService; + +import com.bigbank.account.AccountFactory; +import com.bigbank.account.AccountService; +import com.bigbank.account.CustomerProfileData; +import com.bigbank.account.StockSummary; + +public class FormServlet extends HttpServlet { + + // private ServletContext mContext; + // public void init(ServletConfig pCfg) throws ServletException { + // mContext = pCfg.getServletContext(); + // } + + @Override + public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException { + + try { + final String action = pReq.getParameter("action"); + + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + AccountService accountServices = (AccountService) moduleContext.locateService(AccountService.class, "AccountServiceComponent"); + if (accountServices == null) { + throw new ServletException("AccountServiceComponent"); + } + ProfileService profileServices = null; + if (!"createAccount".equals(action)) { + profileServices = moduleContext.locateService(ProfileService.class, "ProfileServiceComponent"); + if (profileServices == null) { + throw new ServletException("ProfileServiceComponent not found."); + } + if (!profileServices.isLoggedIn()) { + throw new ServletException("User id '" + profileServices.getId() + "' not logged on."); + } + } + + if ("createAccount".equals(action)) { + createAccount(pReq, pResp, accountServices); + } else if ("account".equals(action)) { + accountTransaction(pReq, pResp, accountServices); + } else if ("stockPurchase".equals(action)) { + stockPurchase(pReq, pResp, profileServices, accountServices); + } else if ("stockSale".equals(action)) { + stockSale(pReq, pResp, profileServices, accountServices); + } else { + throw new IllegalArgumentException("Unknown action in Form servlet '" + action + "'."); + } + // mContext.getRequestDispatcher("summary.jsp").forward(pReq, pResp); + pResp.sendRedirect("summary.jsp"); + } catch (ServletException e) { + e.printStackTrace(); + throw e; + + } catch (Exception e) { + + throw new ServletException(e); + } + + } + + private void stockSale(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices) + throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + + int quantity = Integer.parseInt(req.getParameter("quantity")); + int purchaseLotNumber = Integer.parseInt(req.getParameter("purchaseLotNumber")); + accountServices.sellStock(purchaseLotNumber, quantity); + } + + } catch (Exception e) { + + throw new ServletException("stockSale " + e.getMessage(), e); + } + + } + + private void stockPurchase(HttpServletRequest req, HttpServletResponse resp, ProfileService profileServices, AccountService accountServices) + throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + + String symbol = req.getParameter("symbol").trim().toUpperCase(); + int quantity = Integer.parseInt(req.getParameter("quantity")); + StockSummary stockSummry = AccountFactory.INSTANCE.createStockSummary(); + stockSummry.setSymbol(symbol); + stockSummry.setQuantity(quantity); + accountServices.purchaseStock(profileServices.getId(), stockSummry); + } + } catch (Exception e) { + throw new ServletException("stockPurchase " + e.getMessage(), e); + } + } + + private void accountTransaction(HttpServletRequest req, HttpServletResponse resp, AccountService accountServices) throws ServletException { + try { + if (!"cancel".equals(req.getParameter("cancel"))) { + String account = req.getParameter("account"); + String amount = req.getParameter("Amount"); + if ("deposit".equals(req.getParameter("actionType"))) { + accountServices.deposit(account, Float.parseFloat(amount)); + } else { + accountServices.withdraw(account, Float.parseFloat(amount)); + } + } + } catch (Exception e) { + throw new ServletException("accountTransaction " + e.getMessage(), e); + } + + } + + private void createAccount(HttpServletRequest pReq, HttpServletResponse pResp, AccountService accountServices) throws ServletException { + try { + CustomerProfileData customerProfileData = AccountFactory.INSTANCE.createCustomerProfileData(); + customerProfileData.setFirstName(pReq.getParameter("firstName")); + customerProfileData.setLastName(pReq.getParameter("lastName")); + customerProfileData.setAddress(pReq.getParameter("address")); + customerProfileData.setEmail(pReq.getParameter("email")); + customerProfileData.setLoginID(pReq.getParameter("loginID")); + customerProfileData.setPassword(pReq.getParameter("password")); + + CustomerProfileData resp = accountServices.createAccount(customerProfileData, "savings".equals(pReq.getParameter("savings")), "checkings" + .equals(pReq.getParameter("checkings"))); + LoginServlet.login(resp.getLoginID(), resp.getPassword()); + + } catch (IOException e) { + throw new ServletException(e); + } + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java new file mode 100644 index 0000000000..784cc4fb40 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/java/bigbank/webclient/ui/LoginServlet.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.webclient.ui; + +import java.io.IOException; +import java.rmi.RemoteException; + +import javax.servlet.ServletConfig; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + +import bigbank.webclient.services.profile.LoginService; + +public class LoginServlet extends HttpServlet { + + @Override + public void init(ServletConfig pCfg) throws ServletException { + + } + + @Override + public void doPost(HttpServletRequest pReq, HttpServletResponse pResp) throws ServletException { + + if ("logout".equals(pReq.getParameter("logout")) || "logoutHIDDEN".equals(pReq.getParameter("logoutHIDDEN"))) { + HttpSession sess = pReq.getSession(); + if (sess != null) { + sess.invalidate(); + } + try { + pResp.sendRedirect("login.html"); + } catch (IOException e) { + + e.printStackTrace(); + throw new ServletException(e); + } + + } else { + pReq.getSession(); // make sure session started. + String login = pReq.getParameter("login"); + String password = pReq.getParameter("password"); + try { + int resp = login(login, password); + if (resp == LoginService.SUCCESS) { + + pResp.sendRedirect("summary.jsp"); + } else { + + pResp.sendRedirect("login.html"); + } + } catch (IOException e) { + throw new ServletException(e); + } + } + } + + static int login(final String login, final String password) throws ServletException { + + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + LoginService loginMgr = moduleContext.locateService(LoginService.class, "LoginServiceComponent"); + + if (loginMgr == null) { + throw new ServletException("LoginManager not found"); + } + + try { + return loginMgr.login(login, password); + } catch (RemoteException e) { + + throw new ServletException(e); + } + + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl new file mode 100644 index 0000000000..980c0cf279 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/resources/wsdl/AccountService.wsdl @@ -0,0 +1,466 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/CustomerProfile.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/CustomerProfile.jsp new file mode 100644 index 0000000000..2dc17a8867 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/CustomerProfile.jsp @@ -0,0 +1,100 @@ + +<%-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +<%-- LINK href="theme/Master.css" rel="stylesheet" type="text/css" --%> +BigBank- Customer Account + +

Customer Account
+
+

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
First name
Last name
Address
email
 
Checkings
Savings
 
Logon ID
Password
+
+   +
+


+

+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld new file mode 100644 index 0000000000..a3d92a2e46 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/bigbank-tags.tld @@ -0,0 +1,127 @@ + + + + 1.0 + 2.0 + BigBank Tags + Tag library containing BigBank tags + + service + bigbank.webclient.tags.sca.ServiceTag + JSP + Places a reference to an SCA Service in the page context + + id + true + false + + + name + true + false + + + + login + bigbank.webclient.tags.sca.LoginBarrierTag + JSP + Redirects if user is not logged in + + profile + true + false + + + url + true + false + + + + + accountStatus + bigbank.webclient.tags.account.AccountStatusTag + JSP + Accesses and iterates the account service + + id + true + false + + + accountService + true + false + + + profileService + true + false + + + + stockStatus + bigbank.webclient.tags.account.StockStatusTag + JSP + Accesses and iterates the stocks + + id + true + false + + + + + accountLog + bigbank.webclient.tags.account.AccountLogTag + JSP + Accesses and iterates the accounts log + + id + true + false + + + accountService + true + false + + + profileService + true + false + + + + stockLog + bigbank.webclient.tags.account.StockLogTag + JSP + Accesses and iterates the stocks log + + id + true + false + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl new file mode 100644 index 0000000000..cf42086edb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/default.scdl @@ -0,0 +1,53 @@ + + + + + + + + + + + AccountServiceComponent + ProfileServiceComponent + + + Anonymous + + + + + + + + + AccountService + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/web.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..398767e345 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,83 @@ + + + + + + Tuscany Bigbank Web UI sample + + login.html + + + + TuscanyFilter + org.apache.tuscany.runtime.webapp.TuscanyFilter + + + TuscanyFilter + /* + + + + tuscany.online + false + + + + + org.apache.tuscany.runtime.webapp.TuscanyContextListener + + + + org.apache.tuscany.runtime.webapp.TuscanySessionListener + + + + org.apache.tuscany.runtime.webapp.TuscanyRequestListener + + + + LoginServlet + bigbank.webclient.ui.LoginServlet + 1 + + + FormServlet + bigbank.webclient.ui.FormServlet + 0 + + + + LoginServlet + /loginAction/* + + + FormServlet + /FormServlet/* + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountLog.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountLog.jsp new file mode 100644 index 0000000000..6e91a14dcc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountLog.jsp @@ -0,0 +1,99 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --%> + + <%@ page import="com.bigbank.account.AccountLogEntry" %> + <%@ page import="com.bigbank.account.StockLogEntry" %> + <%@ page session="true" %> + <%@ page autoFlush="true" %> + <%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %> + + + BigBank Account and Stock Log + + + + Account Log + + + + + + + + + + + + + + + + +
SeqAccountActionAmount
+ + + + + + + +
+ + + +
+ Stock Log + + + + + + + + <%-- spacer --%> + + + + + + + + + <%-- spacer --%> + + + + + + +
SeqSymbolQuantity  ActionPurchaseLotNumber
+ + + + + +    + + + +
+ + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountTransaction.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountTransaction.jsp new file mode 100644 index 0000000000..4017834867 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/accountTransaction.jsp @@ -0,0 +1,50 @@ + +<%-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + + + +BigBank - <%=request.getParameter("account") %> + + +

Account <%= request.getParameter("account") %>
+
+
+

+
+ + + +Amount to <%=request.getParameter("transaction")%>
+
+
+
+      +
+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/login.html b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/login.html new file mode 100644 index 0000000000..a1a5440a4f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/login.html @@ -0,0 +1,60 @@ + + +Welcome to Big Bank + + + +
+ + + + +
Please login in to access your account
+ + + + + + + + + + + +   + +   + +
Login(test)
Password(password)
+
+


+
+
+
New to Big Bank? Please open a new account with us. +
+

+ + +

+ + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/purchaseStock.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/purchaseStock.jsp new file mode 100644 index 0000000000..90c3a813b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/purchaseStock.jsp @@ -0,0 +1,59 @@ + +<%-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +BigBank- Stock purchase + +

Stock purchase
+
+

+
+ + + + + + + + + + + + + + + + + + + +
Symbol
Quantity
+
+   +
+


+

+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/stockSale.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/stockSale.jsp new file mode 100644 index 0000000000..a2b08f4352 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/stockSale.jsp @@ -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. + --%> + + + +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" + pageEncoding="ISO-8859-1"%> + + +BigBank- Stock sale + +

Stock sale
+
+

+
+ + + + + + + + + + + + + + + + +
Quantity
+
+   +
+


+

+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/summary.jsp b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/summary.jsp new file mode 100644 index 0000000000..f31ded242f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/main/webapp/summary.jsp @@ -0,0 +1,144 @@ +<%-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --%> + + <%@ page import="com.bigbank.account.AccountSummary" %> + <%@ page import="com.bigbank.account.StockSummary" %> + <%@ page session="true" %> + <%@ page autoFlush="true" %> +<%@ taglib uri="/WEB-INF/bigbank-tags.tld" prefix="sca" %> + + + + + BigBank Account Summary + + + + Account Information for +
+ + + +    +
+ + + + + + + + + + + + + + + + + + + + + +
Account Balance
+ + + + + + + + + + +
+ + + +
+
+ Stocks:     
+
+ + + + + + + + <%-- spacer --%> + + + + + + <%-- spacer --%> + + + +
+
+ + + + <%-- spacer --%> + + + + + + + + <%-- spacer --%> + + + + +
SymbolQuantityPurchase Date  Purchase PriceCurrent PriceCompany NameToday HighToday Low   <%-- sell button --%>
+ + + + + +    + + + + + + + + + +    +
+ +
+ +
+
+ Account and Stock Logs:     
+
+ + + + +
diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.java new file mode 100644 index 0000000000..d5ece151de --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestAccountService.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 bigbank.webclient.client; + +import java.util.List; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + + +import com.bigbank.account.AccountReport; +import com.bigbank.account.AccountService; + +public class TestAccountService { + + + public static void main(String[] args) throws Exception { + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + + AccountService accountService = (AccountService) moduleContext.locateService(AccountService.class, "AccountServiceComponent"); + + AccountReport report = accountService.getAccountReport(12345); + List summaries = report.getAccountSummaries(); + + System.out.println("retrieved " + summaries.size() + " summaries"); + + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.java new file mode 100644 index 0000000000..9af80e99db --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/bigbank/webclient/src/test/java/bigbank/webclient/client/TestLoginService.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 bigbank.webclient.client; + +import org.osoa.sca.CompositeContext; +import org.osoa.sca.CurrentCompositeContext; + + +import bigbank.webclient.services.profile.LoginService; + +public class TestLoginService { + + + + public static void main(String[] args) throws Exception { + + CompositeContext moduleContext = CurrentCompositeContext.getContext(); + LoginService loginService = moduleContext.locateService(LoginService.class, "LoginServiceComponent"); + + if (loginService.login("test", "password") == LoginService.SUCCESS) { + System.out.println("Success"); + } else { + System.out.println("Failure"); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/README b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/README new file mode 100644 index 0000000000..65077c5881 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/README @@ -0,0 +1,77 @@ +Binding Echo Sample +=================== +This sample demonstrates how new bindings are constructed for Apache Tuscany +SCA using the lazy-loading approach where extensions are loaded only when they +are encountered during the processing of a composite defintion (SCDL) + +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 want to try out the echo binding that this sample provides +please see the binding-echo sample that provides the necessary client and +application code to bring up an application that uses this binding + +Sample Overview +--------------- +This sample contains a implementation of an SCA binding that simply echoes back +any messages that are sent to it. + +binding-echo2-extension/ + src/ + main/ + java/ + echo2/ + extension/ - The bindings model classes, runtime classes + server/ - A dummy server that the binding is plugged into + resources/ + META-INF/ + services/ + org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor - specifies the + artifact processors to be loaded + org.apache.tuscany.sca.provider.BindingProviderFactory - specifies the model classes for this binding + test/ + java/ + echo2/ - test code + resources/ + EchoBinding.composite - the SCA assembly used by the unit test + build.xml - the Ant build file + pom.xml - the Maven build file + + +Building The Sample Using Ant +----------------------------- +With the binary distribution the sample can be built using Ant as +follows + +cd binding-echo2-extension +ant compile + +See the binding-echo sample to run a sample that uses this binding. + +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 binding-echo2-extension +mvn + +Maven will also test that the sample extension built properly. You should see +the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running echo.EchoReferenceTestCase +Returned message: foo +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.111 sec +Running echo.EchoServiceTestCase +Returned message: foo +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.121 sec + +Results : + +Tests run: 2, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/build.xml new file mode 100644 index 0000000000..cfbdb1e1d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/pom.xml new file mode 100644 index 0000000000..8d0f31dd23 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/pom.xml @@ -0,0 +1,78 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-binding-echo2-extension + Apache Tuscany Echo Binding Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + test + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBinding.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBinding.java new file mode 100644 index 0000000000..d6439bfa13 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBinding.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo2.extension; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sca.assembly.Binding; + +/** + * Implementation of the Echo binding model. + */ +public class EchoBinding implements Binding { + + private String name; + private String uri; + + public String getName() { + return name; + } + + public String getURI() { + return uri; + } + + public void setName(String name) { + this.name = name; + } + + public void setURI(String uri) { + this.uri = uri; + } + + public boolean isUnresolved() { + // The sample binding is always resolved + return false; + } + + public void setUnresolved(boolean unresolved) { + // The sample binding is always resolved + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingInvoker.java new file mode 100644 index 0000000000..70a6e4a43a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingInvoker.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo2.extension; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +/** + * Invoker for the sample echo binding. + */ +public class EchoBindingInvoker implements Invoker { + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + + // echo back the first parameter, a real binding would invoke some API for flowing the request + Object result = args[0]; + + msg.setBody(result); + + } catch (Exception e) { + msg.setFaultBody(e); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingProviderFactory.java new file mode 100644 index 0000000000..f750641d1d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoBindingProviderFactory.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 echo2.extension; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.BindingProviderFactory; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + + +/** + * Implementation of the Echo binding model. + */ +public class EchoBindingProviderFactory implements BindingProviderFactory { + + private MessageFactory messageFactory; + + public EchoBindingProviderFactory(ExtensionPointRegistry registry) { + ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class); + this.messageFactory = factories.getFactory(MessageFactory.class); + } + + public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component, RuntimeComponentReference reference, EchoBinding binding) { + return new EchoReferenceBindingProvider(component, reference, binding); + } + + public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component, RuntimeComponentService service, EchoBinding binding) { + return new EchoServiceBindingProvider(component, service, binding, messageFactory); + } + + public Class getModelType() { + return EchoBinding.class; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoReferenceBindingProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoReferenceBindingProvider.java new file mode 100644 index 0000000000..27659f79a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoReferenceBindingProvider.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo2.extension; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ReferenceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; + +/** + * Implementation of the Echo binding provider. + */ +public class EchoReferenceBindingProvider implements ReferenceBindingProvider { + + private RuntimeComponentReference reference; + + public EchoReferenceBindingProvider(RuntimeComponent component, + RuntimeComponentReference reference, + EchoBinding binding) { + this.reference = reference; + } + + public Invoker createInvoker(Operation operation, boolean isCallback) { + if (isCallback) { + throw new UnsupportedOperationException(); + } else { + return new EchoBindingInvoker(); + } + } + + public InterfaceContract getBindingInterfaceContract() { + return reference.getInterfaceContract(); + } + + public void start() { + } + + public void stop() { + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoServiceBindingProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoServiceBindingProvider.java new file mode 100644 index 0000000000..65ba66b5a6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/extension/EchoServiceBindingProvider.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 echo2.extension; + +import org.apache.tuscany.sca.interfacedef.InterfaceContract; +import org.apache.tuscany.sca.invocation.InvocationChain; +import org.apache.tuscany.sca.invocation.MessageFactory; +import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.apache.tuscany.sca.runtime.RuntimeWire; + +import echo2.server.EchoServer; +import echo2.server.EchoServiceListener; + +/** + * Implementation of the Echo binding provider. + */ +public class EchoServiceBindingProvider implements ServiceBindingProvider { + + private RuntimeComponent component; + private RuntimeComponentService service; + private EchoBinding binding; + private MessageFactory messageFactory; + + public EchoServiceBindingProvider(RuntimeComponent component, + RuntimeComponentService service, EchoBinding binding, MessageFactory messageFactory) { + this.component = component; + this.service = service; + this.binding = binding; + this.messageFactory = messageFactory; + } + + public InterfaceContract getBindingInterfaceContract() { + return service.getInterfaceContract(); + } + + public void start() { + + RuntimeComponentService componentService = (RuntimeComponentService) service; + RuntimeWire wire = componentService.getRuntimeWire(binding); + InvocationChain chain = wire.getInvocationChains().get(0); + + // Register with the hosting server + String uri = binding.getURI(); + EchoServer.getServer().register(uri, new EchoServiceListener(chain.getHeadInvoker(), messageFactory)); + } + + public void stop() { + + // Unregister from the hosting server + String uri = component.getURI() + "/" + binding.getName(); + EchoServer.getServer().unregister(uri); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServer.java new file mode 100644 index 0000000000..fff8ad564f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServer.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package echo2.server; + +import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; +import java.util.Map; + +/** + * A sample Echo server, showing how to integrate service bindings. + */ +public class EchoServer { + + public static EchoServer server; + + private Map services = new HashMap(); + + public static void start() { + } + + public static void stop() { + } + + public static EchoServer getServer() { + if (server == null) + server = new EchoServer(); + return server; + } + + /** + * Register a service under the given name. + * + * @param service + * @param name + */ + public void register(String uri, EchoServiceListener service) { + if (services.isEmpty()) { + start(); + } + services.put(uri, service); + } + + public void unregister(String uri) { + services.remove(uri); + if (services.isEmpty()) { + stop(); + } + } + + /** + * Dispatch an incoming interaction to the corresponding service. + * + * @param uri + * @param input + * @return + */ + public String sendReceive(String uri, String input) throws InvocationTargetException { + return services.get(uri).sendReceive(input); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServiceListener.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServiceListener.java new file mode 100644 index 0000000000..c0010c4ccf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/java/echo2/server/EchoServiceListener.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 echo2.server; + +import java.lang.reflect.InvocationTargetException; + +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.invocation.MessageFactory; + +/** + * The EchoService listener + */ +public class EchoServiceListener { + private Invoker invoker; + private MessageFactory messageFactory; + + public EchoServiceListener(Invoker invoker, MessageFactory messageFactory) { + super(); + this.invoker = invoker; + this.messageFactory = messageFactory; + } + + public String sendReceive(String input) throws InvocationTargetException { + + // Create a request message + Message request = messageFactory.createMessage(); + request.setBody(new Object[] {input}); + + // Dispatch and get the response + Message response = invoker.invoke(request); + Object body = response.getBody(); + if (response.isFault()) { + throw new InvocationTargetException((Throwable)body); + } + return (String)body; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..6671e5d9aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://echo2#binding.echo,model=echo2.extension.EchoBinding diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory new file mode 100644 index 0000000000..e487bf98da --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.BindingProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the binding extension +echo2.extension.EchoBindingProviderFactory;model=echo2.extension.EchoBinding diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/Echo.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/Echo.java new file mode 100644 index 0000000000..4dbe0f9539 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/Echo.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo2; + +/** + * Interface of our sample Echo service. + * + * @version $Rev$ $Date$ + */ +public interface Echo { + + String echo(String msg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoComponentImpl.java new file mode 100644 index 0000000000..83b2db8064 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoComponentImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo2; + +import org.osoa.sca.annotations.Constructor; +import org.osoa.sca.annotations.Reference; + + +/** + * A simple client component that uses a reference with an Echo binding. + * + * @version $Rev$ $Date$ + */ +public class EchoComponentImpl implements Echo { + + private Echo echoReference; + + @Constructor + public EchoComponentImpl(@Reference(name = "echoReference", required = true) Echo echoReference) { + this.echoReference = echoReference; + } + + public String echo(String msg) { + String result = echoReference.echo(msg); + System.out.println("Returned message: "+ result); + return result; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoReferenceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoReferenceTestCase.java new file mode 100644 index 0000000000..e9a9e1590f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoReferenceTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo2; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * @version $Rev$ $Date$ + */ +public class EchoReferenceTestCase extends TestCase { + + private SCADomain scaDomain; + private Echo service; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoBinding.composite"); + service = scaDomain.getService(Echo.class, "EchoComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testEchoBinding() { + String result = service.echo("foo"); + assertEquals(result, "foo"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoServiceTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoServiceTestCase.java new file mode 100644 index 0000000000..077c4fb51d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/java/echo2/EchoServiceTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package echo2; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import echo2.server.EchoServer; + +/** + * @version $Rev$ $Date$ + */ +public class EchoServiceTestCase extends TestCase { + + private SCADomain scaDomain; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("EchoBinding.composite"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void testEchoBinding() throws Exception { + String result = EchoServer.getServer().sendReceive("http://tempuri.org", "foo"); + assertEquals(result, "foo"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/resources/EchoBinding.composite b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/resources/EchoBinding.composite new file mode 100644 index 0000000000..ebd79c736d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/binding-echo2-extension/src/test/resources/EchoBinding.composite @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/README b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/README new file mode 100644 index 0000000000..973c13d00c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/README @@ -0,0 +1,87 @@ +Implementation CRUD Sample +========================== +This sample demonstrates how new implementation types are constructed for +Apache Tuscany SCA. + +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 want to try out the CRUD implementation type that this sample provides +please see the implementation-crud sample that provides the necessary client +code to bring up an application that uses this implementation extension. + +Sample Overview +--------------- +This sample contains a CRUD implementation type as an example of how to create +new implementation types. Components using this implementation type always +expose the same Create, Retrieve, Update and Delete interface. This sample +uses a singleton ResourceManager to perform the CRUD operations but of course +a real component would provide a real implementation. + +implementation-crud-extension/ + src/ + main/ + java/ + crud/ - implementation model interfaces + backend/ - fake component implementation + impl/ - implementations of the model interfaces + module/ - gets the implementation-crud module registered + with the SCA runtime + provider/ - runtime implementation + resources/ + META-INF/ + services/ + org.apache.sca.tuscany.sca.core.ModuleActivator - specifies the + module activation class to call + test/ + java/ + crud/ + CRUDTestCase.java - JUnit test case + resources/ + crud.composite - the SCA assembly used during unit testing + + build.xml - the Ant build file + pom.xml - the Maven build file + +Building The Sample Extension Using Ant +----------------------------------------- +With the binary distribution the sample extension can be built using Ant as +follows + +cd implementation-crud-extension +ant compile + +See the implementation-crud sample to run a sample that uses this +implementation extension. + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built +using Maven as follows. + +cd implementation-crud-extension +mvn + +Maven will also test that the sample extension built properly. You should see +the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running crud.CRUDTestCase +Starting CRUDServiceComponent +create(ABC) in tmp +retrieve(0) +update(0) +retrieve(0) +delete(0) +retrieve(0) +Stopping CRUDServiceComponent +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.212 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/build.xml new file mode 100644 index 0000000000..0f1a0a2270 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/build.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/pom.xml new file mode 100644 index 0000000000..3bc75bfd58 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/pom.xml @@ -0,0 +1,77 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-implementation-crud2-extension + Apache Tuscany CRUD Implementation Extension Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-assembly + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-interface-java-xml + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-core-spi + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.java new file mode 100644 index 0000000000..49ed376809 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/CRUD.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 crud2; + +/** + * The service interface of the single CRUD service provided by CRUD components. + */ +public interface CRUD { + + /** + * Create a new resource. + * @param resource + * @return + */ + String create(Object resource); + + /** + * Retrieve a resource. + * @param id + * @return + */ + Object retrieve(String id); + + /** + * Update a resource. + * @param id + * @param resource + * @return + */ + Object update(String id, Object resource); + + /** + * Delete a resource. + * @param id + */ + void delete(String id); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java new file mode 100644 index 0000000000..aa94cd55b6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/backend/ResourceManager.java @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package crud2.backend; + +import java.util.HashMap; +import java.util.Map; + +/** + * A fake resource manager implementation used as a backend by the sample + * CRUD component implementation. + */ +public class ResourceManager { + private static int counter; + private static final Map store = new HashMap(); + private String directory; + + /** + * Constructs a new resource manager. + * + * @param directory the directory where to persist resources + */ + public ResourceManager(String directory) { + super(); + this.directory = directory; + } + + /** + * Creates a new resource. + * + * @param resource + * @return + */ + public String createResource(Object resource) { + System.out.println("create(" + resource + ") in " + directory); + String key = String.valueOf(counter++); + store.put(key, resource); + return key; + } + + /** + * Deletes a resource. + * + * @param id + */ + public void deleteResource(String id) { + System.out.println("delete(" + id + ")"); + store.remove(id); + } + + /** + * Retrieves a resource. + * + * @param id + * @return + */ + public Object retrieveResource(String id) { + System.out.println("retrieve(" + id + ")"); + return store.get(id); + } + + /** + * Updates a resource. + * + * @param id + * @param resource + * @return + */ + public Object updateResource(String id, Object resource) { + System.out.println("update(" + id + ")"); + return store.put(id, resource); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java new file mode 100644 index 0000000000..0887a98df6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementation.java @@ -0,0 +1,128 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package crud2.extension; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; +import org.apache.tuscany.sca.assembly.Implementation; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; +import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; + +import crud2.CRUD; + + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + */ +public class CRUDImplementation implements Implementation { + + private Service crudService; + private String directory; + + /** + * Constructs a new CRUD implementation. + */ + public CRUDImplementation() { + + // CRUD implementation always provide a single service exposing + // the CRUD Java interface, create the model representing that + // fixed service here + + // Create a default service named CRUD + AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(); + crudService = assemblyFactory.createService(); + crudService.setName("CRUD"); + + // Create a Java interface model for the CRUD Java interface + JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(); + JavaInterface javaInterface; + try { + javaInterface = javaFactory.createJavaInterface(CRUD.class); + } catch (InvalidInterfaceException e) { + throw new IllegalArgumentException(e); + } + + // Create a Java interface contract model and set it + // into the service + JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract(); + interfaceContract.setInterface(javaInterface); + crudService.setInterfaceContract(interfaceContract); + } + + public String getDirectory() { + return directory; + } + + public void setDirectory(String directory) { + this.directory = directory; + } + + public ConstrainingType getConstrainingType() { + // The sample CRUD implementation does not support constrainingTypes + return null; + } + + public List getProperties() { + // The sample CRUD implementation does not support properties + return Collections.emptyList(); + } + + public List getServices() { + // The sample CRUD implementation provides a single fixed CRUD service + return Collections.singletonList(crudService); + } + + public List getReferences() { + // The sample CRUD implementation does not support properties + return Collections.emptyList(); + } + + public String getURI() { + // The sample CRUD implementation does not have a URI + return null; + } + + public void setConstrainingType(ConstrainingType constrainingType) { + // The sample CRUD implementation does not support constrainingTypes + } + + public void setURI(String uri) { + // The sample CRUD implementation does not have a URI + } + + public boolean isUnresolved() { + // The sample CRUD implementation is always resolved + return false; + } + + public void setUnresolved(boolean unresolved) { + // The sample CRUD implementation is always resolved + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.java new file mode 100644 index 0000000000..3040dac612 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationInvoker.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 crud2.extension; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; + +import crud2.backend.ResourceManager; + +/** + * Implements a target invoker for CRUD component implementations. + * + * The target invoker is responsible for dispatching invocations to the particular + * component implementation logic. In this example we are simply delegating the + * CRUD operation invocations to the corresponding methods on our fake + * resource manager. + */ +public class CRUDImplementationInvoker implements Invoker { + private Operation operation; + private ResourceManager resourceManager; + + public CRUDImplementationInvoker(Operation operation, ResourceManager resourceManager) { + this.operation = operation; + this.resourceManager = resourceManager; + } + + public Message invoke(Message msg) { + try { + Object[] args = msg.getBody(); + Object resp = null; + + if (operation.getName().equals("create")) { + resp = resourceManager.createResource(args[0]); + + } else if (operation.getName().equals("retrieve")) { + resp = resourceManager.retrieveResource((String)args[0]); + + } else if (operation.getName().equals("update")) { + resp = resourceManager.updateResource((String)args[0], args[1]); + + } else if (operation.getName().equals("delete")) { + resourceManager.deleteResource((String)args[0]); + } + + msg.setBody(resp); + } catch (Exception e) { + msg.setFaultBody(e.getCause()); + } + return msg; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.java new file mode 100644 index 0000000000..1135ce75cf --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProvider.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 crud2.extension; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; + +import crud2.backend.ResourceManager; + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +public class CRUDImplementationProvider implements ImplementationProvider { + + private RuntimeComponent component; + private CRUDImplementation implementation; + + /** + * Constructs a new CRUD implementation. + */ + public CRUDImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { + this.component = component; + this.implementation = implementation; + } + + public void start() { + System.out.println("Starting " + component.getName()); + } + + public void stop() { + System.out.println("Stopping " + component.getName()); + } + + public Invoker createInvoker(RuntimeComponentService service, Operation operation) { + CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory())); + return invoker; + } + + public Invoker createCallbackInvoker(Operation operation) { + CRUDImplementationInvoker invoker = new CRUDImplementationInvoker(operation, new ResourceManager(implementation.getDirectory())); + return invoker; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.java new file mode 100644 index 0000000000..a4d92ccedd --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/java/crud2/extension/CRUDImplementationProviderFactory.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 crud2.extension; + +import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.provider.ImplementationProvider; +import org.apache.tuscany.sca.provider.ImplementationProviderFactory; +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * The model representing a sample CRUD implementation in an SCA assembly model. + * The sample CRUD implementation is not a full blown implementation, it only + * supports a subset of what a component implementation can support: - a single + * fixed service (as opposed to a list of services typed by different + * interfaces) - a directory attribute used to specify where a CRUD component is + * going to persist resources - no references or properties - no policy intents + * or policy sets + */ +public class CRUDImplementationProviderFactory implements ImplementationProviderFactory { + + public CRUDImplementationProviderFactory(ExtensionPointRegistry registry) { + } + + public Class getModelType() { + // Returns the type of model processed by this processor + return CRUDImplementation.class; + } + + public ImplementationProvider createImplementationProvider(RuntimeComponent component, CRUDImplementation implementation) { + return new CRUDImplementationProvider(component, implementation); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor new file mode 100644 index 0000000000..4b922f4d28 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the artifact processor extension +org.apache.tuscany.sca.assembly.xml.DefaultBeanModelProcessor;qname=http://crud2#implementation.crud,model=crud2.extension.CRUDImplementation diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory new file mode 100644 index 0000000000..5ac1827889 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/main/resources/META-INF/services/org.apache.tuscany.sca.provider.ImplementationProviderFactory @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Implementation class for the implementation extension +crud2.extension.CRUDImplementationProviderFactory;model=crud2.extension.CRUDImplementation diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.java new file mode 100644 index 0000000000..3bc86cef80 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/java/crud2/CRUDTestCase.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 crud2; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import crud2.CRUD; + +/** + * Tests the CRUD service + */ +public class CRUDTestCase extends TestCase { + + private SCADomain scaDomain; + private CRUD crudService; + + /** + * @throws java.lang.Exception + */ + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("crud2.composite"); + crudService = scaDomain.getService(CRUD.class, "CRUDServiceComponent"); + + } + + /** + * @throws java.lang.Exception + */ + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + + public void testCRUD() throws Exception { + String id = crudService.create("ABC"); + Object result = crudService.retrieve(id); + assertEquals("ABC", result); + crudService.update(id, "EFG"); + result = crudService.retrieve(id); + assertEquals("EFG", result); + crudService.delete(id); + result = crudService.retrieve(id); + assertNull(result); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite new file mode 100644 index 0000000000..5aa4b3c7d6 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/old/implementation-crud2-extension/src/test/resources/crud2.composite @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/build-bundles.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/build-bundles.xml new file mode 100644 index 0000000000..7a31e6016b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/build-bundles.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/pom.xml new file mode 100644 index 0000000000..6cfa54796e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/pom.xml @@ -0,0 +1,187 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-osgi-supplychain + Apache Tuscany OSGi Supply Chain Sample + + + + + org.apache.felix + org.apache.felix.main + 1.0.0 + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-osgi + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + sample-osgi-supplychain + + + org.apache.maven.plugins + maven-antrun-plugin + 1.1 + + + + ant + ant-trax + 1.6.5 + + + + + + create-bundles + generate-test-sources + + run + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/readme.htm b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/readme.htm new file mode 100644 index 0000000000..f6948ab471 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/readme.htm @@ -0,0 +1,332 @@ + + + + + + + Tuscany Supply Chain + + + + + +

Tuscany +Supply Chain Sample using OSGi
+

+

Overview

+

The Tuscany OSGi supply chain sample shows using the Tuscany SCA +runtime in a J2SE environment executing the SCA asynchronous API +with OSGi and Java implementation types.

+

Location

+This +sample is located  in the samples\osgi-supplychain directory.
+

Setup

+This sample depends on the Tuscany runtime +and the sample jar, both of +these must be available on the classpath to run the sample. +

Running

+In the directory samples\osgi-supplychain +use the JDK 1.5 java command to run the class supplychain.SupplyChainClient +
Linux:   java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-osgi-supplychain.jar supplychain.SupplyChainClient
+
Windows: java -cp ..\..\lib\tuscany-sca-manifest.jar;target\sample-osgi-supplychain.jar supplychain.SupplyChainClient
+

Results

+

The sample when run should simply display on the standard output +some startup messages followed by:
+
+Work thread Thread[Thread-1,5,main] +- Order, submitted, fulfilled, shipped

+

Code Overview

+The source files are physically organized as shown below: + + + + + + +
src
++---main
+    ++---java
+    +¦   +---supplychain
+    ¦ +         OSGiBundleImpl.java
+    ¦ +         SupplyChainClient.java
+    +¦         +---customer
+    +¦            +    +Customer.java
+    +¦                +JavaCustomerComponentImpl.java
+    +¦                +OSGiCustomerComponentImpl.java
+    +¦                +OSGiCustomerImpl.java
+    +¦         +---retailer
+    +¦            +    +Retailer.java
+    +¦                +JavaRetailerComponentImpl.java
+    +¦                +OSGiRetailerComponentImpl.java
+    +¦                +OSGiRetailerImpl.java
+    +¦         +---shipper
+    +¦                +Shipper.java
+    +¦                +JavaShipperComponentImpl.java
+    +¦                +OSGiShipperComponentImpl.java
+    +¦                +OSGiShipperImpl.java
+    +¦         +---warehouse
+    +¦               +Warehouse.java
+    +¦               +JavaWarehouseComponentImpl.java
+    +¦               +OSGiWarehouseComponentImpl.java
+    +¦               +OSGiWarehouseImpl.java
+    +¦
+    +---resources
+    +¦   +---osgi
+    ¦ +         Customer.mf
+    ¦ +         Retailer.mf
+    ¦ +         Shipper.mf
+    ¦ +         Warehouse.mf
+    ¦        ++---ds
+    ¦         +      Customer.mf
+    ¦          +     Retailer.mf
+    ¦ +              +Shipper.mf
+    ¦ +              +Warehouse.mf
+    ¦         +      Customer.xml
+    ¦          +     Retailer.xml
+    ¦ +              +Shipper.xml
+    ¦ +              +Warehouse.xml
+    ¦      +Customer.componentType
+    ¦      +Retailer.componentType
+    ¦      +Shipper.componentType
+    ¦      +Warehouse.componentType
+    ¦      +supplychain.composite
+    ¦      +supplychain.ds.composite
+  
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Customer.javaDefines the Java interface implemented by the Customer +component.
JavaCustomerComponentImpl.javaPOJO Implementation of the SCA Customer component.
OSGiCustomerComponentImpl.javaOSGi Declarative Services +Implementation of the SCA Customer component.
OSGiCustomerImpl.javaOSGi Procedural Services +Implementation of the SCA Customer component.
Retailer.javaDefines the Java interface implemented by the Retailer +component.
JavaRetailerComponentImpl.javaPOJO Implementation of  the SCA RetailerComponent +component.
OSGiRetailerComponentImpl.javaOSGi Declarative Services +Implementation of the SCA Retailer component.
OSGiRetailerImpl.javaOSGi Procedural Services +Implementation of the SCA Retailer component.
Shipper.javaDefines +the Java interface implemented by the Shipper component
JavaShipperComponentImpl.javaPOJO Implementation of the SCA ShipperComponent +component.
OSGiShipperComponentImpl.javaOSGi Declarative Services +Implementation of the SCA Shipper component.
OSGiShipperImpl.javaOSGi Procedural Services Implementation of the SCA Shipper +component.
Warehouse.javaDefines +the Java interface implemented by the Warehouse component.
JavaWarehouseComponentImpl.javaPOJO Implementation of the SCA WarehouseComponent +component.
OSGiWarehouseComponentImpl.javaOSGi Declarative Services +Implementation of the SCA Warehouse component.
OSGiWarehouseImpl.javaOSGi Procedural Services +Implementation of the SCA Warehouse component.
OSGiBundleImpl.java
+
Common code for OSGi Procedural +Services Implementation of the SCA components
+
SupplyChainClient.javaSupplyChainClient.java +loads SCA runtime
+
SupplyChainClientTestCase.javaJUnit test for this sample
+
resources/osgi/*.mf
+
Manifest files for OSGi bundles +for OSGi procedural services implementation
+
resources/osgi/ds/*.mfManifest files for OSGi bundles +for OSGi declarative services implementation
resources/osgi/ds/*.xmlOSGi Declarative services +component xml files
+
resources/*.componentType
+
Component types used by OSGi +implementation provider for SCA
+
resources/supplychain.composite
+
Composite file using OSGi and +Java implementation types
+
resources/supplychain.ds.compositeComposite file using OSGi +(declarative services) and Java implementation types
+
+
+ + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java new file mode 100644 index 0000000000..d357c622c3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/OSGiBundleImpl.java @@ -0,0 +1,123 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + + +import java.lang.reflect.Field; +import java.util.Hashtable; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceEvent; +import org.osgi.framework.ServiceListener; +import org.osgi.framework.ServiceReference; + + +/** + * Common code for all OSGi bundles which dont use declarative services. + * Registers services and sets references. + */ +public class OSGiBundleImpl implements ServiceListener, BundleActivator { + + + String name; + String serviceName; + String[] references; + Class[] referenceClasses; + Field[] referenceFields; + + Class myClass; + + private BundleContext bundleContext; + + public OSGiBundleImpl(String serviceName, String... references) { + + System.out.println("Created " + this.getClass().getSimpleName()); + + myClass = this.getClass(); + this.name = this.getClass().getSimpleName(); + this.serviceName = serviceName; + this.references = references; + + try { + referenceClasses = new Class[references.length]; + referenceFields = new Field[references.length]; + for (int i = 0; i < references.length; i++) { + referenceFields[i] = this.getClass().getDeclaredField(references[i]); + referenceFields[i].setAccessible(true); + referenceClasses[i] = referenceFields[i].getType(); + } + + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + public void start(BundleContext bc) { + + System.out.println("Started bundle " + name); + + this.bundleContext = bc; + + bundleContext.registerService(serviceName, this, new Hashtable()); + + for (int i = 0; i < references.length; i++) { + + try { + + ServiceReference ref = bundleContext.getServiceReference(referenceClasses[i].getName()); + if (ref != null) { + Object obj = bundleContext.getService(ref); + referenceFields[i].set(this, referenceClasses[i].cast(obj)); + } else { + String filter = "(objectclass=" + referenceClasses[i].getName() + ")"; + this.bundleContext.addServiceListener(this, filter); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + public void stop(BundleContext bc) { + System.out.println("Stop bundle " + name); + + } + + + public void serviceChanged(ServiceEvent event) { + try { + if (event.getType() == ServiceEvent.REGISTERED) { + + ServiceReference ref = event.getServiceReference(); + Object obj = bundleContext.getService(ref); + for (int i = 0; i < references.length; i++) { + if (referenceClasses[i].isAssignableFrom(obj.getClass())) { + referenceFields[i].set(this, referenceClasses[i].cast(obj)); + } + } + } + } catch (Throwable e) { + e.printStackTrace(); + } + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java new file mode 100644 index 0000000000..64814487cb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/SupplyChainClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import supplychain.customer.Customer; + + +/** + * This client program shows how to create an SCA runtime, start it, + * locate a Customer service component and invoke it. + */ +public class SupplyChainClient { + + public static final void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("supplychain.composite"); + Customer customer = scaDomain.getService(Customer.class, "CustomerComponent"); + + System.out.println("Main thread " + Thread.currentThread()); + customer.purchaseGoods(); + System.out.println("Main thread sleeping ..."); + Thread.sleep(1000); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.java new file mode 100644 index 0000000000..225dce0236 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/Customer.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 supplychain.customer; + +import org.osoa.sca.annotations.OneWay; + +/** + * This is the business interface of the Customer service component. + */ +public interface Customer { + + public void purchaseGoods(); + + @OneWay + public void notifyShipment(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java new file mode 100644 index 0000000000..447efbae6e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/JavaCustomerComponentImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.customer; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.retailer.Retailer; + +/** + * This class implements the Customer service component (POJO implementation). + */ +@Service(Customer.class) +@Scope("COMPOSITE") +public class JavaCustomerComponentImpl implements Customer { + + private Retailer retailer; + + @Reference + public void setRetailer(Retailer retailer) { + this.retailer = retailer; + } + + public void purchaseGoods() { + System.out.println("Customer.purchaseGoods, retailer is " + retailer); + retailer.submitOrder("Order"); + } + + public void notifyShipment(String order) { + System.out.print("Work thread " + Thread.currentThread() + " - "); + System.out.println(order); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.java new file mode 100644 index 0000000000..580e1289b7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerComponentImpl.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 supplychain.customer; + + +import supplychain.retailer.Retailer; + +/** + * This class implements the Customer service component (OSGi declarative services implementation). + */ +public class OSGiCustomerComponentImpl implements Customer { + + + private Retailer retailer; + + + protected void setRetailer(Retailer retailer) { + this.retailer = retailer; + } + + protected void unsetRetailer(Retailer retailer) { + this.retailer = null; + } + + public void purchaseGoods() { + System.out.println("Customer.purchaseGoods, retailer is " + retailer); + retailer.submitOrder("Order"); + } + + public void notifyShipment(String order) { + System.out.print("Work thread " + Thread.currentThread() + " - "); + System.out.println(order); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.java new file mode 100644 index 0000000000..e1557bc6d8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/customer/OSGiCustomerImpl.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 supplychain.customer; + + +import supplychain.OSGiBundleImpl; +import supplychain.retailer.Retailer; + +/** + * This class implements the Customer service component (OSGi procedural services implementation). + */ +public class OSGiCustomerImpl extends OSGiBundleImpl implements Customer { + + private Retailer retailer; + + public OSGiCustomerImpl() { + super("supplychain.customer.Customer", "retailer"); + + } + + public void purchaseGoods() { + System.out.println("Customer.purchaseGoods, retailer is " + retailer); + retailer.submitOrder("Order"); + } + + public void notifyShipment(String order) { + System.out.print("Work thread " + Thread.currentThread() + " - "); + System.out.println(order); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.java new file mode 100644 index 0000000000..7a8caaafe3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/JavaRetailerComponentImpl.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 supplychain.retailer; + + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.warehouse.Warehouse; + +/** + * This class implements the Retailer service component (POJO implementation). + */ +@Service(Retailer.class) +@Scope("STATELESS") +public class JavaRetailerComponentImpl implements Retailer { + + private Warehouse warehouse; + + + @Reference + public void setWarehouse(Warehouse warehouse) { + this.warehouse = warehouse; + } + + + public void submitOrder(String order) { + + System.out.println("Retailer.submitOrder, warehouse is " + warehouse); + warehouse.fulfillOrder(order + ", submitted"); + + } + + + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.java new file mode 100644 index 0000000000..2112043613 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerComponentImpl.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 supplychain.retailer; + +import supplychain.warehouse.Warehouse; + +/** + * This class implements the Retailer service component (OSGi declarative services implementation). + */ +public class OSGiRetailerComponentImpl implements Retailer { + + private Warehouse warehouse; + + + protected void setWarehouse(Warehouse warehouse) { + this.warehouse = warehouse; + } + + protected void unsetWarehouse(Warehouse warehouse) { + this.warehouse = null; + } + + public void submitOrder(String order) { + + System.out.println("Retailer.submitOrder, warehouse is" + warehouse); + warehouse.fulfillOrder(order + ", submitted"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java new file mode 100644 index 0000000000..f8f86b418c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/OSGiRetailerImpl.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.retailer; + + +import supplychain.OSGiBundleImpl; +import supplychain.warehouse.Warehouse; + +/** + * This class implements the Retailer service component (OSGi procedural services implementation). + */ +public class OSGiRetailerImpl extends OSGiBundleImpl implements Retailer { + + private Warehouse warehouse; + + public OSGiRetailerImpl() { + + super("supplychain.retailer.Retailer", "warehouse"); + } + + public void submitOrder(String order) { + + System.out.println("Retailer.submitOrder, warehouse is " + warehouse); + warehouse.fulfillOrder(order + ", submitted"); + + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java new file mode 100644 index 0000000000..1e87d59af1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/retailer/Retailer.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.retailer; + +/** + * This is the business interface of the Retailer service component. + */ +public interface Retailer { + + public void submitOrder(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.java new file mode 100644 index 0000000000..d0fb30fc04 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/JavaShipperComponentImpl.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 supplychain.shipper; + + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.customer.Customer; + +/** + * This class implements the Shipper service component (POJO implementation). + */ +@Service(Shipper.class) +@Scope("COMPOSITE") +public class JavaShipperComponentImpl implements Shipper { + + private Customer customer; + + @Reference + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public void processShipment(String order) { + System.out.println("Shipper.processShipment, customer is " + customer); + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java new file mode 100644 index 0000000000..8278e2957f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperComponentImpl.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.shipper; + + +import supplychain.customer.Customer; + +/** + * This class implements the Shipper service component (OSGi declarative services implementation). + */ +public class OSGiShipperComponentImpl implements Shipper { + + private Customer customer; + + + protected void setCustomer(Customer customer) { + this.customer = customer; + } + + protected void unsetCustomer(Customer customer) { + this.customer = null; + } + + public void processShipment(String order) { + System.out.println("Shipper.processShipment, customer is " + customer); + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java new file mode 100644 index 0000000000..4eaa14e4db --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/OSGiShipperImpl.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.shipper; + + +import supplychain.OSGiBundleImpl; +import supplychain.customer.Customer; + +/** + * This class implements the Shipper service component (OSGi procedural services implementation). + */ +public class OSGiShipperImpl extends OSGiBundleImpl implements Shipper { + + private Customer customer; + + public OSGiShipperImpl() { + super("supplychain.shipper.Shipper", "customer"); + } + + + public void processShipment(String order) { + System.out.println("Shipper.processShipment, customer is " + customer); + customer.notifyShipment(order + ", shipped"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java new file mode 100644 index 0000000000..2514928c10 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/shipper/Shipper.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.shipper; + +/** + * This is the business interface of the Shipper service component. + */ +public interface Shipper { + + public void processShipment(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.java new file mode 100644 index 0000000000..bf153b481c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/JavaWarehouseComponentImpl.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 supplychain.warehouse; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component (POJO implementation). + */ +@Service(Warehouse.class) +@Scope("STATELESS") +public class JavaWarehouseComponentImpl implements Warehouse { + + private Shipper shipper; + + + @Reference + public void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + public void fulfillOrder(String order) { + System.out.println("Warehouse.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.java new file mode 100644 index 0000000000..63e5725a43 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseComponentImpl.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 supplychain.warehouse; + +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service component (OSGi declarative services implementation). + */ + +public class OSGiWarehouseComponentImpl implements Warehouse { + + private Shipper shipper; + + + protected void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + protected void unsetShipper(Shipper shipper) { + this.shipper = null; + } + + public void fulfillOrder(String order) { + System.out.println("Warehouse.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + + } + + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java new file mode 100644 index 0000000000..27f95c1752 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/OSGiWarehouseImpl.java @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.warehouse; + + +import supplychain.OSGiBundleImpl; +import supplychain.shipper.Shipper; + +/** + * This class implements the Warehouse service componentm (OSGi procedural services implementation). + */ + +public class OSGiWarehouseImpl extends OSGiBundleImpl implements Warehouse { + + private Shipper shipper; + + public OSGiWarehouseImpl() { + super("supplychain.warehouse.Warehouse", "shipper"); + } + + + public void fulfillOrder(String order) { + System.out.println("Warehouse.fulfillOrder : shipper is " + shipper); + + shipper.processShipment(order + ", fulfilled"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java new file mode 100644 index 0000000000..6f1f6b8730 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/java/supplychain/warehouse/Warehouse.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain.warehouse; + +/** + * This is the business interface of the Warehouse service component. + */ +public interface Warehouse { + + public void fulfillOrder(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Customer.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Customer.componentType new file mode 100644 index 0000000000..5c61a0961c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Customer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/LICENSE.txt b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..0084319535 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, serviceDefinition marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/NOTICE b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..d83ebbe236 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/NOTICE @@ -0,0 +1,14 @@ +${pom.name} +Copyright (c) 2005 - 2006 The Apache Software Foundation + +Apache Tuscany is an effort undergoing incubation at The Apache Software +Foundation (ASF), sponsored by the Apache Web Services PMC. Incubation is +required of all newly accepted projects until a further review indicates that +the infrastructure, communications, and decision making process have stabilized +in a manner consistent with other successful ASF projects. While incubation +status is not necessarily a reflection of the completeness or stability of the +code, it does indicate that the project has yet to be fully endorsed by the ASF. + +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/README.txt b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Retailer.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Retailer.componentType new file mode 100644 index 0000000000..15185f2bf9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Retailer.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Shipper.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Shipper.componentType new file mode 100644 index 0000000000..675597d80b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Shipper.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Warehouse.componentType b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Warehouse.componentType new file mode 100644 index 0000000000..6e1ac3e5a9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/Warehouse.componentType @@ -0,0 +1,28 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf new file mode 100644 index 0000000000..88d79e5219 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Customer.mf @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Customer +Bundle-SymbolicName: supplychain.customer.Customer +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + supplychain.retailer +Export-Package: supplychain.customer +Bundle-Activator: supplychain.customer.OSGiCustomerImpl + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf new file mode 100644 index 0000000000..d95ef5d582 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Retailer.mf @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Retailer +Bundle-SymbolicName: supplychain.retailer.Retailer +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + supplychain.warehouse +Export-Package: supplychain.retailer +Bundle-Activator: supplychain.retailer.OSGiRetailerImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf new file mode 100644 index 0000000000..de7ac7ec7a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Shipper.mf @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Shipper +Bundle-SymbolicName: supplychain.shipper.Shipper +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + supplychain.customer +Export-Package: supplychain.shipper +Bundle-Activator: supplychain.shipper.OSGiShipperImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf new file mode 100644 index 0000000000..21241a6899 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/Warehouse.mf @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Warehouse +Bundle-SymbolicName: supplychain.warehouse.Warehouse +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + supplychain.shipper +Export-Package: supplychain.warehouse +Bundle-Activator: supplychain.warehouse.OSGiWarehouseImpl diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf new file mode 100644 index 0000000000..b5c5a862be --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.mf @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Customer +Bundle-SymbolicName: ds.supplychain.customer.Customer +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + org.osgi.service.component, supplychain.retailer +Export-Package: supplychain.customer +Service-Component: osgi/ds/Customer.xml diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml new file mode 100644 index 0000000000..961b22b3c7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Customer.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf new file mode 100644 index 0000000000..47897d16ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.mf @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Retailer +Bundle-SymbolicName: ds.supplychain.retailer.Retailer +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + org.osgi.service.component, + supplychain.warehouse +Export-Package: supplychain.retailer +Service-Component: osgi/ds/Retailer.xml diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml new file mode 100644 index 0000000000..dc4c39b549 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Retailer.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf new file mode 100644 index 0000000000..f5333c7caa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.mf @@ -0,0 +1,10 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Shipper +Bundle-SymbolicName: ds.supplychain.shipper.Shipper +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + org.osgi.service.component, supplychain.customer +Export-Package: supplychain.shipper +Service-Component: osgi/ds/Shipper.xml diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml new file mode 100644 index 0000000000..b05f23c7cc --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Shipper.xml @@ -0,0 +1,34 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf new file mode 100644 index 0000000000..6166549e5a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.mf @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Warehouse +Bundle-SymbolicName: ds.supplychain.warehouse.Warehouse +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Import-Package: org.osgi.framework, + org.osgi.service.component, + supplychain.shipper +Export-Package: supplychain.warehouse +Service-Component: osgi/ds/Warehouse.xml diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml new file mode 100644 index 0000000000..dcbbc2b543 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/osgi/ds/Warehouse.xml @@ -0,0 +1,33 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..3afcb88c58 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite new file mode 100644 index 0000000000..72ea783ea7 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/main/resources/supplychain.ds.composite @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java new file mode 100644 index 0000000000..ba166cea00 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/osgi-supplychain/src/test/java/supplychain/SupplyChainClientTestCase.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 supplychain; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + + +import supplychain.customer.Customer; + +/** + * This client program shows how to create an SCA runtime, start it, locate a simple HelloWorld service component and + * invoke it. + */ +public class SupplyChainClientTestCase extends TestCase { + + private SCADomain scaDomain; + private Customer customer; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("supplychain.composite"); + customer = scaDomain.getService(Customer.class, "CustomerComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + + public void test() throws Exception { + + + System.out.println("In SupplyChainClientTestCase.test: Calling customer.purchaseGoods, customer is " + customer); + + customer.purchaseGoods(); + + System.out.println("Sleeping ..."); + Thread.sleep(2000); + System.out.println("Test complete"); + + } + + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/pom.xml new file mode 100644 index 0000000000..1ecf20384f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/pom.xml @@ -0,0 +1,80 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../pom.xml + + tuscany-samples + pom + Apache Tuscany SCA Samples + + + + default + + true + + + binding-echo + binding-echo-extension + binding-notification-broker + binding-notification-consumer + binding-notification-producer + calculator + calculator-distributed + calculator-rmi-reference + calculator-rmi-service + calculator-script + calculator-webapp + calculator-webapp-ws + chat-webapp + databinding-echo + feed-aggregator + helloworld-dojo + helloworld-jsonrpc + helloworld-ws-service + helloworld-ws-reference + helloworld-ws-sdo + implementation-composite + implementation-crud + implementation-crud-extension + implementation-notification + implementation-pojo-extension + loanapplication + osgi-supplychain + + simple-bigbank + simple-bigbank-spring + simple-callback + simple-callback-ws + supplychain + web-resource + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/pom.xml new file mode 100644 index 0000000000..387a25eaea --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/pom.xml @@ -0,0 +1,168 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-quote-xquery + Apache Tuscany XQuery Quote Implementation Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-xquery + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + 1.0-incubating + + + + org.apache.tuscany.sdo + tuscany-sdo-impl + 1.0-incubating + + + + net.sf.saxon + saxon + 8.9 + + + + org.apache.tuscany.sca + tuscany-databinding-sdo + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-http-jetty + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + compile + + + + + + ${artifactId} + + + org.codehaus.mojo + build-helper-maven-plugin + 1.0 + + + add-source + generate-sources + + add-test-source + + + + target/sdo-source + + + + + + + org.apache.tuscany.sdo + tuscany-sdo-plugin + 1.0-incubating + + + generate-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/Quote.xsd + + + generate + + + + generate-avail-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/AvailQuote.xsd + + + generate + + + + generate-price-quote-sdo + generate-sources + + ${basedir}/src/main/resources/wsdl/PriceQuote.xsd + + + generate + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.java new file mode 100644 index 0000000000..146939c190 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderImpl.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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.osoa.sca.annotations.Service; + +@Service(AvailQuoteProviderService.class) +public class AvailQuoteProviderImpl implements AvailQuoteProviderService { + + public AvailQuote provideAvailQuote(String dummyString) { + return TestHelper.buildAvailQuoteData(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..ac55c02efa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderNodeInfo.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 xquery.quote; + +import net.sf.saxon.om.NodeInfo; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface AvailQuoteProviderNodeInfo { + NodeInfo provideAvailQuote(String dummyString); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.java new file mode 100644 index 0000000000..2715be19a9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/AvailQuoteProviderService.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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface AvailQuoteProviderService { + AvailQuote provideAvailQuote(String dummyString); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.java new file mode 100644 index 0000000000..84abb5c520 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/ExternalReferencesQuoteJoin.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 xquery.quote; + +import org.example.quote.Quote; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface ExternalReferencesQuoteJoin { + public Quote joinPriceAndAvailQuotes(float taxRate); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.java new file mode 100644 index 0000000000..a8bfc6ca1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProvider.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 xquery.quote; + +import org.example.price.PriceQuote; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface PriceQuoteProvider { + + public PriceQuote providePriceQuote(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.java new file mode 100644 index 0000000000..cbd71f6279 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderImpl.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 xquery.quote; + +import org.example.price.PriceQuote; + +public class PriceQuoteProviderImpl implements PriceQuoteProvider { + public PriceQuote providePriceQuote() { + return TestHelper.buildPriceQuoteData(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.java new file mode 100644 index 0000000000..c95c979c64 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PriceQuoteProviderNodeInfo.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 xquery.quote; + +import net.sf.saxon.om.NodeInfo; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface PriceQuoteProviderNodeInfo { + public NodeInfo providePriceQuote(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.java new file mode 100644 index 0000000000..3a70f619a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/PropertiesQuoteJoin.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 xquery.quote; + +import org.example.quote.Quote; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface PropertiesQuoteJoin { + public Quote joinPriceAndAvailQuotes(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java new file mode 100644 index 0000000000..0b90c9fb0f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculator.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface QuoteCalculator { + public float calculateTotalPrice(float taxRate, int quantity, float price, boolean fillOrder); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.java new file mode 100644 index 0000000000..34fd24fbe5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteCalculatorImpl.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 xquery.quote; + +public class QuoteCalculatorImpl implements QuoteCalculator { + + public float calculateTotalPrice(float taxRate, int quantity, float price, + boolean fillOrder) { + float totalTax, costNoTax, totalCost; + if (fillOrder) + { + // Calculate the total tax + totalTax = taxRate * quantity * price; + // Calculate the total cost without tax + costNoTax = quantity * price; + // Add the tax and the cost to get the total cost + totalCost = totalTax + costNoTax; + } + else + { + totalCost = 0; + } + return totalCost; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.java new file mode 100644 index 0000000000..fd16c4b4c5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoin.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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.osoa.sca.annotations.Remotable; +import org.osoa.sca.annotations.Service; + +@Remotable +@Service +public interface QuoteJoin { + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.java new file mode 100644 index 0000000000..5d1c7066fe --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocal.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 xquery.quote; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; + +public interface QuoteJoinLocal { + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); + public Quote joinPriceAndAvailQuotesWs(PriceQuote priceQuote, AvailQuote availQuote, float taxRate); + public Quote joinPriceAndAvailQuotes(); + public Quote joinPriceAndAvailQuotes(float taxRate); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java new file mode 100644 index 0000000000..2eff74fbc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/QuoteJoinLocalImpl.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.osoa.sca.annotations.Reference; + +public class QuoteJoinLocalImpl implements QuoteJoinLocal { + private QuoteJoin quoteJoin; + private QuoteJoin quoteJoinWs; + private PropertiesQuoteJoin propertiesQuoteJoin; + private ExternalReferencesQuoteJoin externalServicesQuoteJoin; + + @Reference + public void setQuoteJoin(QuoteJoin quoteJoin) { + this.quoteJoin = quoteJoin; + } + + @Reference + public void setQuoteJoinWs(QuoteJoin quoteJoinWs) { + this.quoteJoinWs = quoteJoinWs; + } + + @Reference + public void setPropertiesQuoteJoin(PropertiesQuoteJoin propertiesQuoteJoin) { + this.propertiesQuoteJoin = propertiesQuoteJoin; + } + + @Reference + public void setExternalServicesQuoteJoin(ExternalReferencesQuoteJoin externalServicesQuoteJoin) { + this.externalServicesQuoteJoin = externalServicesQuoteJoin; + } + + public Quote joinPriceAndAvailQuotes(PriceQuote priceQuote, AvailQuote availQuote, float taxRate) { + return quoteJoin.joinPriceAndAvailQuotes(priceQuote, availQuote, taxRate); + } + + public Quote joinPriceAndAvailQuotesWs(PriceQuote priceQuote, AvailQuote availQuote, float taxRate) { + return quoteJoinWs.joinPriceAndAvailQuotes(priceQuote, availQuote, taxRate); + } + + public Quote joinPriceAndAvailQuotes(float taxRate) { + return externalServicesQuoteJoin.joinPriceAndAvailQuotes(taxRate); + } + + public Quote joinPriceAndAvailQuotes() { + return propertiesQuoteJoin.joinPriceAndAvailQuotes(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/TestHelper.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/TestHelper.java new file mode 100644 index 0000000000..65b4df0468 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/java/xquery/quote/TestHelper.java @@ -0,0 +1,144 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + + +import java.io.IOException; +import java.math.BigInteger; +import java.util.List; + +import junit.framework.TestCase; + +import org.example.avail.AvailFactory; +import org.example.avail.AvailQuote; +import org.example.avail.AvailRequest; +import org.example.price.PriceFactory; +import org.example.price.PriceQuote; +import org.example.price.PriceRequest; +import org.example.price.PriceRequests; +import org.example.price.ShipAddress; +import org.example.quote.Quote; +import org.example.quote.QuoteResponse; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.impl.HelperProvider; + +public class TestHelper { + + public static AvailQuote buildAvailQuoteData() { + AvailQuote availQuote = AvailFactory.INSTANCE.createAvailQuote(); + AvailRequest availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(12)); + availRequest.setRequestedQuantity(10); + availRequest.setQuantityAvail(true); + availRequest.setShipDate("2003-03-22"); + availQuote.getAvailRequest().add(availRequest); + + availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(134)); + availRequest.setRequestedQuantity(345); + availRequest.setQuantityAvail(false); + availRequest.setShipDate("BackOrder"); + availQuote.getAvailRequest().add(availRequest); + + availRequest = AvailFactory.INSTANCE.createAvailRequest(); + availRequest.setWidgetId(BigInteger.valueOf(211)); + availRequest.setRequestedQuantity(100); + availRequest.setQuantityAvail(true); + availRequest.setShipDate("2003-04-21"); + availQuote.getAvailRequest().add(availRequest); + + return availQuote; + } + + public static PriceQuote buildPriceQuoteData() { + PriceQuote priceQuote = PriceFactory.INSTANCE.createPriceQuote(); + priceQuote.setCustomerName("Acme Inc"); + + ShipAddress shipAddress = PriceFactory.INSTANCE.createShipAddress(); + shipAddress.setStreet("12 Springs Rd"); + shipAddress.setCity("Morris Plains"); + shipAddress.setState("nj"); + shipAddress.setZip("07960"); + priceQuote.setShipAddress(shipAddress); + + PriceRequests priceRequests = PriceFactory.INSTANCE.createPriceRequests(); + PriceRequest priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(12)); + priceRequest.setPrice(1.00f); + priceRequests.getPriceRequest().add(priceRequest); + + priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(134)); + priceRequest.setPrice(34.10f); + priceRequests.getPriceRequest().add(priceRequest); + + priceRequest = PriceFactory.INSTANCE.createPriceRequest(); + priceRequest.setWidgetId(BigInteger.valueOf(211)); + priceRequest.setPrice(10.00f); + priceRequests.getPriceRequest().add(priceRequest); + + priceQuote.setPriceRequests(priceRequests); + + return priceQuote; + } + + public static void assertQuote(AvailQuote availQuote, PriceQuote priceQuote, Quote quote, float taxRate) { + QuoteCalculatorImpl quoteCalculatorImpl = new QuoteCalculatorImpl(); + + TestCase.assertEquals(priceQuote.getCustomerName(), quote.getName()); + ShipAddress shipAddress = priceQuote.getShipAddress(); + TestCase.assertEquals(shipAddress.getStreet()+","+shipAddress.getCity()+","+shipAddress.getState().toUpperCase()+","+shipAddress.getZip(), quote.getAddress()); + List availRequests = availQuote.getAvailRequest(); + List priceRequests = priceQuote.getPriceRequests().getPriceRequest(); + List quoteResponses = quote.getQuoteResponse(); + TestCase.assertEquals(availRequests.size(), priceRequests.size()); + TestCase.assertEquals(availRequests.size(), quoteResponses.size()); + + for(int i=0; i + { data($priceQuoteDoc/priceQuote/customerName) } +
{ concat($priceQuoteDoc/priceQuote/shipAddress/@street , ",", $priceQuoteDoc/priceQuote/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/priceQuote/shipAddress/@state) , ",", $priceQuoteDoc/priceQuote/shipAddress/@zip) }
+ { + for $priceRequest in $priceQuoteDoc/priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/availQuote/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + $taxRate, + $availRequest/requestedQuantity, + $priceRequest/price, + $availRequest/quantityAvail) } + + } + +}; \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq new file mode 100644 index 0000000000..d6c6356080 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_external_references.xq @@ -0,0 +1,49 @@ +declare namespace quoteJoin="scaservice:java/xquery.quote.ExternalReferencesQuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace priceQuoteProvider="scareference:java/xquery.quote.PriceQuoteProviderNodeInfo"; +declare namespace availQuoteProvider="scareference:java/xquery.quote.AvailQuoteProviderNodeInfo"; + +declare variable $quoteCalculator external; + +declare variable $priceQuoteProvider external; +declare variable $availQuoteProvider external; + +declare function quoteJoin:joinPriceAndAvailQuotes($taxRate) { +let $priceQuoteDoc := priceQuoteProvider:providePriceQuote($priceQuoteProvider) +let $availQuoteDoc := availQuoteProvider:provideAvailQuote($availQuoteProvider, 'dummy') +return + + { data($priceQuoteDoc/priceQuote/customerName) } +
{ concat($priceQuoteDoc/priceQuote/shipAddress/@street , ",", $priceQuoteDoc/priceQuote/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/priceQuote/shipAddress/@state) , ",", $priceQuoteDoc/priceQuote/shipAddress/@zip) }
+ { + for $priceRequest in $priceQuoteDoc/priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/availQuote/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + $taxRate, + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } +
+}; \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq new file mode 100644 index 0000000000..62275b41f8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/META-INF/sca/quote_join_properties.xq @@ -0,0 +1,48 @@ +declare namespace quoteJoin="scaservice:java/xquery.quote.PropertiesQuoteJoin"; + +declare namespace quoteCalculator="scareference:java/xquery.quote.QuoteCalculator"; + +declare namespace priceQuoteDoc="scaproperty:xml/http://www.example.org/price:priceQuote"; +declare namespace availQuoteDoc="scaproperty:xml/http://www.example.org/avail:availQuote"; +declare namespace taxRate="scaproperty:java/java.lang.Float"; + +declare variable $quoteCalculator external; + +declare variable $priceQuoteDoc external; +declare variable $availQuoteDoc external; +declare variable $taxRate external; + +declare function quoteJoin:joinPriceAndAvailQuotes() { + + { data($priceQuoteDoc/priceQuote/customerName) } +
{ concat($priceQuoteDoc/priceQuote/shipAddress/@street , ",", $priceQuoteDoc/priceQuote/shipAddress/@city ,",", fn:upper-case($priceQuoteDoc/priceQuote/shipAddress/@state) , ",", $priceQuoteDoc/priceQuote/shipAddress/@zip) }
+ { + for $priceRequest in $priceQuoteDoc/priceQuote/priceRequests/priceRequest, + $availRequest in $availQuoteDoc/availQuote/availRequest + where data($priceRequest/widgetId) = data($availRequest/widgetId) + return + + { data($priceRequest/widgetId) } + { data($priceRequest/price) } + { data($availRequest/requestedQuantity) } + { data($availRequest/quantityAvail) } + { + for $shipDate in $availRequest/shipDate + return + { data($shipDate) } + } + { $taxRate } + { quoteCalculator:calculateTotalPrice( + $quoteCalculator, + + $taxRate, + + $availRequest/requestedQuantity, + + $priceRequest/price, + + $availRequest/quantityAvail) } + + } +
+}; \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd new file mode 100644 index 0000000000..e7f3e67068 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/AvailQuote.xsd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd new file mode 100644 index 0000000000..4c437586ef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/PriceQuote.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd new file mode 100644 index 0000000000..4f64850056 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/Quote.xsd @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/availquoteprovider.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/availquoteprovider.wsdl new file mode 100644 index 0000000000..f4744c8a14 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/availquoteprovider.wsdl @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl new file mode 100644 index 0000000000..b48dc2117b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/wsdl/quotejoin.wsdl @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotews.composite b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotews.composite new file mode 100644 index 0000000000..fc360d7d6f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotews.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite new file mode 100644 index 0000000000..dbdf2b677c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/main/resources/xqueryquotewsclient.composite @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + Acme Inc + + + + 12 + 1.0 + + + 134 + 34.1 + + + 211 + 10.0 + + + + + + + + 12 + 10 + true + 2003-03-22 + + + 134 + 345 + false + BackOrder + + + 211 + 100 + true + 2003-04-21 + + + + 0.1 + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java new file mode 100644 index 0000000000..97febf65e9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteClientTestCase.java @@ -0,0 +1,145 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.host.embedded.SCATestCaseRunner; +import org.example.avail.AvailQuote; +import org.example.price.PriceQuote; +import org.example.quote.Quote; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import commonj.sdo.DataObject; + +/** + * Integration test for the XQuery implementation type + * @version $Rev$ $Date$ + * This test covers the most important integration scenarios for the xquery + * implementation type and its corresponding saxon data bindings: + * + * 1. There is a central component for invoking the different + * scenarios: QuoteJoinLocalComponent + * 2. It provides the following tests: + * - invoke XQuery component in the current assembly, by providing all needed + * information as input parameters + * - invoke XQuery component in external assembly, which is exposed as a web + * service + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from the component properties + * - invoke XQuery component in the current assembly, which retrieves the needed + * information from its references to other components: + * - one of the components is in the current assembly + * - the other component is in anther assembly and it is exposed (and accessed) + * as web service + * + * 3. All of the XQuery components have reference to a component for calculation of the + * total price + * 4. SDO is used for data interchange + */ +public class XQueryQuoteClientTestCase { + + public static boolean SHOW_DEBUG_MSG = false; + + private SCADomain scaDomain; + private SCATestCaseRunner server; + + private QuoteJoinLocal quoteJoinLocal; + + @Before + public void startClient() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotewsclient.composite"); + + quoteJoinLocal = scaDomain.getService(QuoteJoinLocal.class, "QuoteJoinLocalComponent"); + + server = new SCATestCaseRunner(XQueryQuoteTestServer.class); + server.before(); + } catch(Throwable t) { + t.printStackTrace(); + } + } + + @Test + public void testQuoteJoin() { + AvailQuote availQuote = TestHelper.buildAvailQuoteData(); + PriceQuote priceQuote = TestHelper.buildPriceQuoteData(); + + if(SHOW_DEBUG_MSG) { + System.out.println("Input quote for the price list:"); + TestHelper.serializeToSystemOut((DataObject)priceQuote, "priceQuote"); + System.out.println(); + System.out.println("Input quote for the availability:"); + TestHelper.serializeToSystemOut((DataObject)availQuote, "availQuote"); + System.out.println(); + } + + Quote quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.1f); + TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + if(SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join:"); + TestHelper.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(priceQuote, availQuote, 0.2f); + TestHelper.assertQuote(availQuote, priceQuote, quote, 0.2f); + if(SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from local join (second invokation):"); + TestHelper.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + + quote = quoteJoinLocal.joinPriceAndAvailQuotesWs(priceQuote, availQuote, 0.1f); + TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + if(SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from web service join:"); + TestHelper.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(); + TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + if(SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from properties join:"); + TestHelper.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + + quote = quoteJoinLocal.joinPriceAndAvailQuotes(0.1f); + TestHelper.assertQuote(availQuote, priceQuote, quote, 0.1f); + if(SHOW_DEBUG_MSG) { + System.out.println(); + System.out.println("Output quote from external references join:"); + TestHelper.serializeToSystemOut((DataObject)quote, "quote"); + System.out.println(); + } + } + + @After + public void stopClient() throws Exception { + server.after(); + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java new file mode 100644 index 0000000000..cc78f4103b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/quote-xquery/src/test/java/xquery/quote/XQueryQuoteTestServer.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package xquery.quote; + +import java.io.IOException; +import java.net.Socket; + +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class XQueryQuoteTestServer { + private SCADomain scaDomain; + + @Before + public void startServer() throws Exception { + try { + scaDomain = SCADomain.newInstance("xqueryquotews.composite"); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Test + public void testPing() throws IOException { + new Socket("127.0.0.1", 8085); + } + + @After + public void stopServer() throws Exception { + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/README b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/README new file mode 100644 index 0000000000..8a8d616857 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/README @@ -0,0 +1,91 @@ +Spring Bigbank Sample +================= +This sample implements a simple a version of the BigBank scenrio used in +various places in the SCA specification documents. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-simple-bigbank-spring.jar bigbank.client.BigBankClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-simple-bigbank-spring.jar bigbank.client.BigBankClient + + +Sample Overview +--------------- +The sample provides a composite with two java components wired together +with a default binding. A request to the AccountComponent results in a +request to the AccountDataComponent to get account data. The data returns +back via the AccountComponent to the client. + +simple-bigbank-spring/ + src/ + main/ + java/ + bigbank/ + account/ - AccountComponent implementation + accountdata/ - AccountDataComponent implementation + client/ - starts the SCA Runtime and + deploys the BigBank.composite. + It then calls the deployed AccountService + resources/ + Account.composite - SCA assembly for this sample + BigBank.composite - SCA assembly for this sample + StockQuote.composite - SCA assembly for this sample + test/ + java/ + bigbank/ + BigBankTestCase.java - JUnit test case + simple-bigbank-spring.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 simple-bigbank-spring +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID +:Foo_SAA12345, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100] + +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 simple-bigbank-spring +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running bigbank.BigBankTestCase +Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID:Foo_SAA1234 +5, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100, balance:10432.0]] +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.592 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/build.xml new file mode 100644 index 0000000000..ecc2596d71 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/pom.xml new file mode 100644 index 0000000000..fd8a0a2546 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/pom.xml @@ -0,0 +1,72 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-simple-bigbank-spring + Apache Tuscany Simplified Spring-Based BigBank Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-spring + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.png b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.png new file mode 100644 index 0000000000..593c047f6a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.svg b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.svg new file mode 100644 index 0000000000..c64f6de6b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/simple-bigbank-spring.svg @@ -0,0 +1,200 @@ + + + + + + + + + + image/svg+xml + + + + + + + + BigBank + + AccountServiceComponent + + + + + AccountDataServiceComponent + + + currency AccountService + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java new file mode 100644 index 0000000000..1625ff5b65 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountReport.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.List; + +/** + */ +public class AccountReport { + private List summaries; + private String currency; + + public AccountReport(String currency, List summaries) { + this.currency = currency; + this.summaries = summaries; + } + + public List getAccountSummaries() { return summaries; } + + public String getCurrency() { return currency; } + + @Override + public String toString() { + return "currency: "+ currency + ", " + summaries; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..7c9082b944 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountService.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 bigbank.account; + +/** + * Interface for a account service + */ +public interface AccountService { + public AccountReport getAccountReport(String customerID); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..ae9071445d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/account/AccountServiceImpl.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.ArrayList; +import java.util.List; + +import bigbank.accountdata.AccountDataService; +import bigbank.accountdata.CheckingAccount; +import bigbank.accountdata.SavingsAccount; +import bigbank.accountdata.StockAccount; +import bigbank.stockquote.StockQuoteService; + +/** + * Account service implementation + */ +public class AccountServiceImpl implements AccountService { + + private AccountDataService accountDataService; + + private StockQuoteService stockQuoteService; + + private String currency; + + public AccountReport getAccountReport(String s) { + List summaries = new ArrayList(); + + CheckingAccount ca = accountDataService.getCheckingAccount(s); + summaries.add(ca.getSummary()); + + SavingsAccount sa = accountDataService.getSavingsAccount(s); + summaries.add(sa.getSummary()); + + StockAccount sk = accountDataService.getStockAccount(s); + + double price = stockQuoteService.getQuote(sk.getSymbol()); + sk.setBalance(sk.getQuantity() * price); + + summaries.add(sk.getSummary()); + + AccountReport report = new AccountReport(currency, summaries); + + return report; + } + + public AccountDataService getAccountDataService() { + return accountDataService; + } + + public void setAccountDataService(AccountDataService accountDataService) { + this.accountDataService = accountDataService; + } + + public String getCurrency() { + return currency; + } + + public void setCurrency(String currency) { + this.currency = currency; + } + + public StockQuoteService getStockQuoteService() { + return stockQuoteService; + } + + public void setStockQuoteService(StockQuoteService stockQuoteService) { + this.stockQuoteService = stockQuoteService; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/Account.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/Account.java new file mode 100644 index 0000000000..a5ae7b3955 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/Account.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 bigbank.accountdata; + +/** + * Interface for a account service + */ +public interface Account { + String getSummary(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataService.java new file mode 100644 index 0000000000..c354de387b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * Interface for a account data service + */ +public interface AccountDataService { + public CheckingAccount getCheckingAccount(String customerID); + public SavingsAccount getSavingsAccount(String customerID); + public StockAccount getStockAccount(String customerID); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..000acb935c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/AccountDataServiceImpl.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 bigbank.accountdata; + + +/** + * Account data service implementation + */ +public class AccountDataServiceImpl implements AccountDataService { + + public CheckingAccount getCheckingAccount(String customerID) { + + CheckingAccount checkingAccount = new CheckingAccount(); + checkingAccount.setAccountNumber(customerID+"_"+"CHA12345"); + checkingAccount.setBalance(1500.0f); + + return checkingAccount; + } + + public SavingsAccount getSavingsAccount(String customerID) { + + SavingsAccount savingsAccount = new SavingsAccount(); + savingsAccount.setAccountNumber(customerID+"_"+"SAA12345"); + savingsAccount.setBalance(1500.0f); + + return savingsAccount; + } + + public StockAccount getStockAccount(String customerID) { + + StockAccount stockAccount = new StockAccount(); + stockAccount.setAccountNumber(customerID+"_"+"STA12345"); + stockAccount.setSymbol("IBM"); + stockAccount.setQuantity(100); + + return stockAccount; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/CheckingAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..11bdff757e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/CheckingAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a checking account + */ +public class CheckingAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/SavingsAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..b791024076 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/SavingsAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a savings account + */ +public class SavingsAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/StockAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/StockAccount.java new file mode 100644 index 0000000000..86246a3f84 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/accountdata/StockAccount.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a stock account + */ +public class StockAccount implements Account { + private String accountNumber; + private String symbol; + private int quantity; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getQuantity() { return quantity; } + public void setQuantity(int a) { this.quantity = a; } + + public String getSymbol() { return symbol; } + public void setSymbol(String s) { this.symbol = s; } + + public double getBalance() { return balance; } + public void setBalance(double balance) { this.balance = balance; } + + public String getSummary() { return "ID:" + accountNumber + ", symbol:" + symbol + ", quantity:" + quantity + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..edbf910d37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/client/BigBankClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.client; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class BigBankClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("BigBank.composite"); + + AccountService accountService = scaDomain.getService(AccountService.class, + "AccountServiceComponent"); + + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..0512d40b0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteImpl.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 bigbank.stockquote; + + +/** + * This class implements the StockQuote service. + */ +public class StockQuoteImpl implements StockQuoteService { + + public double getQuote(String symbol) { + double price = 104.0 + Math.random(); + price = ((int)(price * 100)) / 100.0; + + System.out.println("Getting stock quote for: " + symbol + ", value: "+ price); + + return price; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..2d97b57066 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/java/bigbank/stockquote/StockQuoteService.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 bigbank.stockquote; + +import org.osoa.sca.annotations.Remotable; + +/** + * This is the business interface of the StockQuote service. + */ +@Remotable +public interface StockQuoteService { + + public double getQuote(String symbol); +} + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/Account-spring-context.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/Account-spring-context.xml new file mode 100644 index 0000000000..2d882472fb --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/Account-spring-context.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/BigBank.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..727327ef30 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/BigBank.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/StockQuote.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..26bdc59075 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/main/resources/StockQuote.composite @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..ba6c1dd797 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank-spring/src/test/java/bigbank/BigBankTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * Tests out the big bank service + * + */ +public class BigBankTestCase extends TestCase { + + private SCADomain scaDomain; + AccountService accountService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("BigBank.composite"); + accountService = scaDomain.getService(AccountService.class, "AccountServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/README b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/README new file mode 100644 index 0000000000..55170005d3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/README @@ -0,0 +1,91 @@ +Calculator Sample +================= +This sample implements a simple a version of the BigBank scenrio used in +various places in the SCA specification documents. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-simple-bigbank.jar bigbank.client.BigBankClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-simple-bigbank.jar bigbank.client.BigBankClient + + +Sample Overview +--------------- +The sample provides a composite with two java components wired together +with a default binding. A request to the AccountComponent results in a +request to the AccountDataComponent to get account data. The data returns +back via the AccountComponent to the client. + +calculator/ + src/ + main/ + java/ + bigbank/ + account/ - AccountComponent implementation + accountdata/ - AccountDataComponent implementation + client/ - starts the SCA Runtime and + deploys the BigBank.composite. + It then calls the deployed AccountService + resources/ + Account.composite - SCA assembly for this sample + BigBank.composite - SCA assembly for this sample + StockQuote.composite - SCA assembly for this sample + test/ + java/ + bigbank/ + BigBankTestCase.java - JUnit test case + simple-bigbank.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 simple-bigbank +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID +:Foo_SAA12345, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100] + +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 simple-bigbank +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running bigbank.BigBankTestCase +Account summary: currency: USD, [ID:Foo_CHA12345, balance:1500.0, ID:Foo_SAA1234 +5, balance:1500.0, ID:Foo_STA12345, symbol:IBM, quantity:100, balance:10432.0]] +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.592 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/build.xml new file mode 100644 index 0000000000..a814014eae --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/pom.xml new file mode 100644 index 0000000000..a1e0307c41 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-simple-bigbank + Apache Tuscany Simplified BigBank Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.png b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.png new file mode 100644 index 0000000000..593c047f6a Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.svg b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.svg new file mode 100644 index 0000000000..c64f6de6b9 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/simple-bigbank.svg @@ -0,0 +1,200 @@ + + + + + + + + + + image/svg+xml + + + + + + + + BigBank + + AccountServiceComponent + + + + + AccountDataServiceComponent + + + currency AccountService + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java new file mode 100644 index 0000000000..1625ff5b65 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountReport.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.account; + +import java.util.List; + +/** + */ +public class AccountReport { + private List summaries; + private String currency; + + public AccountReport(String currency, List summaries) { + this.currency = currency; + this.summaries = summaries; + } + + public List getAccountSummaries() { return summaries; } + + public String getCurrency() { return currency; } + + @Override + public String toString() { + return "currency: "+ currency + ", " + summaries; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.java new file mode 100644 index 0000000000..7c9082b944 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountService.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 bigbank.account; + +/** + * Interface for a account service + */ +public interface AccountService { + public AccountReport getAccountReport(String customerID); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.java new file mode 100644 index 0000000000..fa85f309c0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/account/AccountServiceImpl.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 bigbank.account; + +import java.util.ArrayList; +import java.util.List; + +import org.osoa.sca.annotations.Property; +import org.osoa.sca.annotations.Reference; + +import bigbank.accountdata.AccountDataService; +import bigbank.accountdata.CheckingAccount; +import bigbank.accountdata.SavingsAccount; +import bigbank.accountdata.StockAccount; +import bigbank.stockquote.StockQuoteService; + +/** + * Account service implementation + */ +public class AccountServiceImpl implements AccountService { + + @Reference + public AccountDataService accountDataService; + + @Reference + public StockQuoteService stockQuoteService; + + @Property + public String currency; + + public AccountReport getAccountReport(String s) { + List summaries = new ArrayList(); + + CheckingAccount ca = accountDataService.getCheckingAccount(s); + summaries.add(ca.getSummary()); + + SavingsAccount sa = accountDataService.getSavingsAccount(s); + summaries.add(sa.getSummary()); + + StockAccount sk = accountDataService.getStockAccount(s); + + double price = stockQuoteService.getQuote(sk.getSymbol()); + sk.setBalance(sk.getQuantity() * price); + + summaries.add(sk.getSummary()); + + AccountReport report = new AccountReport(currency, summaries); + + return report; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.java new file mode 100644 index 0000000000..a5ae7b3955 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/Account.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 bigbank.accountdata; + +/** + * Interface for a account service + */ +public interface Account { + String getSummary(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java new file mode 100644 index 0000000000..c354de387b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataService.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * Interface for a account data service + */ +public interface AccountDataService { + public CheckingAccount getCheckingAccount(String customerID); + public SavingsAccount getSavingsAccount(String customerID); + public StockAccount getStockAccount(String customerID); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.java new file mode 100644 index 0000000000..000acb935c --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/AccountDataServiceImpl.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 bigbank.accountdata; + + +/** + * Account data service implementation + */ +public class AccountDataServiceImpl implements AccountDataService { + + public CheckingAccount getCheckingAccount(String customerID) { + + CheckingAccount checkingAccount = new CheckingAccount(); + checkingAccount.setAccountNumber(customerID+"_"+"CHA12345"); + checkingAccount.setBalance(1500.0f); + + return checkingAccount; + } + + public SavingsAccount getSavingsAccount(String customerID) { + + SavingsAccount savingsAccount = new SavingsAccount(); + savingsAccount.setAccountNumber(customerID+"_"+"SAA12345"); + savingsAccount.setBalance(1500.0f); + + return savingsAccount; + } + + public StockAccount getStockAccount(String customerID) { + + StockAccount stockAccount = new StockAccount(); + stockAccount.setAccountNumber(customerID+"_"+"STA12345"); + stockAccount.setSymbol("IBM"); + stockAccount.setQuantity(100); + + return stockAccount; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java new file mode 100644 index 0000000000..11bdff757e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/CheckingAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a checking account + */ +public class CheckingAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java new file mode 100644 index 0000000000..b791024076 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/SavingsAccount.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a savings account + */ +public class SavingsAccount implements Account { + private String accountNumber; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getBalance() { return balance; } + public void setBalance(double b) { this.balance = b; } + + public String getSummary() { return "ID:" + accountNumber + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java new file mode 100644 index 0000000000..86246a3f84 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/accountdata/StockAccount.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.accountdata; + +/** + * An account service implementation for a stock account + */ +public class StockAccount implements Account { + private String accountNumber; + private String symbol; + private int quantity; + private double balance; + + public String getAccountNumber() { return accountNumber; } + public void setAccountNumber(String n) { this.accountNumber = n; } + + public double getQuantity() { return quantity; } + public void setQuantity(int a) { this.quantity = a; } + + public String getSymbol() { return symbol; } + public void setSymbol(String s) { this.symbol = s; } + + public double getBalance() { return balance; } + public void setBalance(double balance) { this.balance = balance; } + + public String getSummary() { return "ID:" + accountNumber + ", symbol:" + symbol + ", quantity:" + quantity + ", balance:" + balance; } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java new file mode 100644 index 0000000000..edbf910d37 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/client/BigBankClient.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package bigbank.client; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +public class BigBankClient { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("BigBank.composite"); + + AccountService accountService = scaDomain.getService(AccountService.class, + "AccountServiceComponent"); + + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + + scaDomain.close(); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.java new file mode 100644 index 0000000000..0512d40b0b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteImpl.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 bigbank.stockquote; + + +/** + * This class implements the StockQuote service. + */ +public class StockQuoteImpl implements StockQuoteService { + + public double getQuote(String symbol) { + double price = 104.0 + Math.random(); + price = ((int)(price * 100)) / 100.0; + + System.out.println("Getting stock quote for: " + symbol + ", value: "+ price); + + return price; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java new file mode 100644 index 0000000000..7961279352 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/java/bigbank/stockquote/StockQuoteService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank.stockquote; + +import org.osoa.sca.annotations.Remotable; + + +/** + * This is the business interface of the StockQuote service. + */ +@Remotable +public interface StockQuoteService { + + public double getQuote(String symbol); +} + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/Account.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/Account.composite new file mode 100644 index 0000000000..e71615e27e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/Account.composite @@ -0,0 +1,38 @@ + + + + + + + + + + USD + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/BigBank.composite new file mode 100644 index 0000000000..c870f39cab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/BigBank.composite @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/StockQuote.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/StockQuote.composite new file mode 100644 index 0000000000..4f29c14851 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/main/resources/StockQuote.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java new file mode 100644 index 0000000000..ba6c1dd797 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-bigbank/src/test/java/bigbank/BigBankTestCase.java @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package bigbank; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +import bigbank.account.AccountService; + +/** + * Tests out the big bank service + * + */ +public class BigBankTestCase extends TestCase { + + private SCADomain scaDomain; + AccountService accountService; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("BigBank.composite"); + accountService = scaDomain.getService(AccountService.class, "AccountServiceComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + System.out.println("Account summary: " + accountService.getAccountReport("Foo") ); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/README b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/README new file mode 100644 index 0000000000..85cd90afef --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/README @@ -0,0 +1,134 @@ +Simple Callback Sample Using Web Services +========================================= +This sample demonstrates asynchronous messaging using a callback over the +Web Service binding. It is very similar to the simple-callback sample. +The only differences are that simplecallback.composite has been updated +to use the Web Service binding, and there is a simplecallback.wsdl file. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-simple-callback.jar simplecallback.SimpleCallbackClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-simple-callback.jar simplecallback.SimpleCallbackClient + + +Sample Overview +--------------- +The sample provides a single composite with two components. MyClientComponent is +wired to MyServiceComponent. The interface of MyServiceComponent describes one +method as ONEWAY and with a callback semantic. When a message passes from +client to service the response is returned via the callback asynchronously. + +simple-callback/ + src/ + main/ + java/ + simplecallback/ + MyClient.java - client interface + MyClientImpl.java - implements the client and service callback + interfaces + MyService.java - service interface + MyServiceCallback.java - service callback interface, implemented by the + client + MyServiceImpl.java - implements the service interface + SimpleCallbackClient.java - starts the SCA Runtime and + deploys the simplecallback.composite. + It then calls MyClientComponent which in turn + calls MyServiceComponent + resources/ + simplecallback.composite - the SCA assembly for this sample + wsdl/ + simplecallback.wsdl - the service description and callback binding + test/ + java/ + simplecallback/ + SimpleCallbackTestCase.java - JUnit test case + simple-callback.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 simple-callback-ws +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAXUtils). + [java] log4j:WARN Please initialize the log4j system properly. + [java] Main thread Thread[main,5,main] + [java] aClientMethod on thread Thread[main,5,main] + [java] setMyServiceCallback on thread Thread[pool-1-thread-3,5,main] + [java] someMethod on thread Thread[pool-1-thread-3,5,main] + [java] receiveResult on thread Thread[Axis2 Task,5,main] + [java] Result: -> someMethod -> receiveResult + [java] aClientMethod return from someMethod on thread Thread[main,5,main] + +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 simple-callback-ws +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running simplecallback.SimpleCallbackTestCase +log4j:WARN No appenders could be found for logger (org.apache.axiom.om.util.StAXUtils). +log4j:WARN Please initialize the log4j system properly. +01-Jul-2007 21:20:06 org.apache.catalina.core.StandardEngine start +INFO: Starting Servlet Engine: Apache Tomcat/6.0.10 +01-Jul-2007 21:20:07 org.apache.catalina.startup.ContextConfig defaultWebConfig +INFO: No default web.xml +01-Jul-2007 21:20:07 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0.xsd +01-Jul-2007 21:20:07 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd +01-Jul-2007 21:20:07 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd +01-Jul-2007 21:20:07 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/jsp/resources/web-jsptaglibrary_2_0.xsd +01-Jul-2007 21:20:07 org.apache.catalina.startup.DigesterFactory register +WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xsd +01-Jul-2007 21:20:07 org.apache.coyote.http11.Http11Protocol init +INFO: Initializing Coyote HTTP/1.1 on http-8080 +01-Jul-2007 21:20:07 org.apache.coyote.http11.Http11Protocol start +INFO: Starting Coyote HTTP/1.1 on http-8080 +Main thread Thread[main,5,main] +aClientMethod on thread Thread[main,5,main] +setMyServiceCallback on thread Thread[pool-1-thread-1,5,main] +someMethod on thread Thread[pool-1-thread-1,5,main] +aClientMethod return from someMethod on thread Thread[main,5,main] +Sleeping ... +receiveResult on thread Thread[Axis2 Task,5,main] +Result: -> someMethod -> receiveResult +01-Jul-2007 21:20:08 org.apache.coyote.http11.Http11Protocol destroy +INFO: Stopping Coyote HTTP/1.1 on http-8080 +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.525 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/build.xml new file mode 100644 index 0000000000..10b69bd395 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/pom.xml new file mode 100644 index 0000000000..8e0e8195a3 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-simple-callback-ws + Apache Tuscany Simple Callback Web Services Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-ws-axis2 + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-http-tomcat + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.png b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.png new file mode 100644 index 0000000000..1b6353f5cf Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.svg b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.svg new file mode 100644 index 0000000000..7d9e3de510 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/simple-callback-ws.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + simplecallback + MyServiceComponent + + + MyClientComponent + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java new file mode 100644 index 0000000000..4cc00d6d0f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClient.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +/** + * The client interface + */ +public interface MyClient { + + void aClientMethod(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java new file mode 100644 index 0000000000..b9479324ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyClientImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Demonstrates a component-to-component callback invocation + */ +@Service(MyClient.class) +@Scope("COMPOSITE") +public class MyClientImpl implements MyClient, MyServiceCallback { + + private MyService myService; + static String result; + + @Reference + public void setMyService(MyService myService) { + this.myService = myService; + } + + public void aClientMethod() { + System.out.println("aClientMethod on thread " + Thread.currentThread()); + myService.someMethod(" -> someMethod "); + System.out.println("aClientMethod return from someMethod on thread " + Thread.currentThread()); + } + + public void receiveResult(String result) { + System.out.println("receiveResult on thread " + Thread.currentThread()); + System.out.println("Result: " + result); + MyClientImpl.result = result; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java new file mode 100644 index 0000000000..48acc0e94f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyService.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; +import org.osoa.sca.annotations.Remotable; + +/** + * This service that will be invoked in a non-blocking fashion + */ +@Remotable +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.java new file mode 100644 index 0000000000..66cfb2bc8a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceCallback.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 simplecallback; + +import org.osoa.sca.annotations.Remotable; + +/** + * The callback interface for {@link MyService}. + */ +@Remotable +public interface MyServiceCallback { + + void receiveResult(String result); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.java new file mode 100644 index 0000000000..3817eb15b0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/MyServiceImpl.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 simplecallback; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements MyService and uses a callback. + */ +@Service(MyService.class) +@Scope("COMPOSITE") +public class MyServiceImpl implements MyService { + + private MyServiceCallback myServiceCallback; + + /** + * The setter used by the runtime to set the callback reference + * @param myServiceCallback + */ + @Callback + public void setMyServiceCallback(MyServiceCallback myServiceCallback) { + System.out.println("setMyServiceCallback on thread " + Thread.currentThread()); + this.myServiceCallback = myServiceCallback; + } + + public void someMethod(String arg) { + System.out.println("someMethod on thread " + Thread.currentThread()); + // invoke the callback + try { + myServiceCallback.receiveResult(arg + " -> receiveResult "); + } catch(RuntimeException e) { + System.out.println("RuntimeException invoking receiveResult: " + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.java new file mode 100644 index 0000000000..eeb0e52163 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/java/simplecallback/SimpleCallbackClient.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 simplecallback; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Demonstrates resolving the client service and initiating the callback sequence + */ +public class SimpleCallbackClient { + + public static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("simplecallback.composite"); + MyClient myClient = scaDomain.getService(MyClient.class, "MyClientComponent"); + + System.out.println("Main thread " + Thread.currentThread()); + myClient.aClientMethod(); + Thread.sleep(1000); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/simplecallback.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/simplecallback.composite new file mode 100644 index 0000000000..8bc5bddfe2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/simplecallback.composite @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl new file mode 100644 index 0000000000..243737dd70 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/main/resources/wsdl/simplecallback.wsdl @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java new file mode 100644 index 0000000000..413737346e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback-ws/src/test/java/simplecallback/SimpleCallbackTestCase.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * A testcase that demonstrates resolving the client service and initiating the callback sequence + */ +public class SimpleCallbackTestCase extends TestCase { + + private SCADomain scaDomain; + private MyClient myClient; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("simplecallback.composite"); + myClient = scaDomain.getService(MyClient.class, "MyClientComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + System.out.println("Main thread " + Thread.currentThread()); + myClient.aClientMethod(); + System.out.println("Sleeping ..."); + Thread.sleep(1300); + assertEquals("-> someMethod -> receiveResult", MyClientImpl.result); + } +} + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/README b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/README new file mode 100644 index 0000000000..719376f254 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/README @@ -0,0 +1,97 @@ +Simple Callback Sample +====================== +This sample demonstrates asynchronous messaging using a callback. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-simple-callback.jar simplecallback.SimpleCallbackClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-simple-callback.jar simplecallback.SimpleCallbackClient + + +Sample Overview +--------------- +The sample provides a single composite with two components. MyClientComponent is +wired to MyServiceComponent. The interface of MyServiceComponent describes one +method as ONEWAY and with a callback semantic. When a message passes from +client to service the response is returned via the callback asynchronously. + +simple-callback/ + src/ + main/ + java/ + simplecallback/ + MyClient.java - client interface + MyClientImpl.java - implements the client and service callback + interfaces + MyService.java - service interface + MyServiceCallback.java - service callback interface, implemented by the + client + MyServiceImpl.java - implements the service interface + SimpleCallbackClient.java - starts the SCA Runtime and + deploys the simplecallback.composite. + It then calls MyClientComponent which in turn + calls MyServiceComponent + resources/ + simplecallback.composite - the SCA assembly for this sample + test/ + java/ + simplecallback/ + SimpleCallbackTestCase.java - JUnit test case + simple-callback.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 simple-callback +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Main thread Thread[main,5,main] + [java] Work thread Thread[pool-1-thread-1,5,main] + [java] Result: -> someMethod -> receiveResult + +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 simple-callback +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running simplecallback.SimpleCallbackTestCase +Main thread Thread[main,5,main] +Sleeping ... +Work thread Thread[pool-1-thread-1,5,main] +Result: -> someMethod -> receiveResult +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.692 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/build.xml new file mode 100644 index 0000000000..47d1ea4bc1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/pom.xml new file mode 100644 index 0000000000..52b4bf621f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-simple-callback + Apache Tuscany Simple Callback Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.png b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.png new file mode 100644 index 0000000000..1b6353f5cf Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.svg b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.svg new file mode 100644 index 0000000000..484b65df9d --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/simple-callback.svg @@ -0,0 +1,150 @@ + + + + + + + + + + image/svg+xml + + + + + + + + simplecallback + MyServiceComponent + + + MyClientComponent + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClient.java new file mode 100644 index 0000000000..4cc00d6d0f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClient.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +/** + * The client interface + */ +public interface MyClient { + + void aClientMethod(); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.java new file mode 100644 index 0000000000..3e2a1df5a5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyClientImpl.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 simplecallback; + +import org.osoa.sca.annotations.Reference; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * Demonstrates a component-to-component callback invocation + */ +@Service(MyClient.class) +@Scope("COMPOSITE") +public class MyClientImpl implements MyClient, MyServiceCallback { + + private MyService myService; + static String result; + + @Reference + public void setMyService(MyService myService) { + this.myService = myService; + } + + public void aClientMethod() { + myService.someMethod("-> someMethod"); + } + + public void receiveResult(String result) { + System.out.println("Work thread " + Thread.currentThread()); + System.out.println("Result: " + result); + MyClientImpl.result = result; + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyService.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyService.java new file mode 100644 index 0000000000..e78ad6f68f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.OneWay; + +/** + * This service that will be invoked in a non-blocking fashion + */ +@Callback(MyServiceCallback.class) +public interface MyService { + + @OneWay + void someMethod(String arg); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java new file mode 100644 index 0000000000..b27eea44f5 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceCallback.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +/** + * The callback interface for {@link MyService}. + */ +public interface MyServiceCallback { + + void receiveResult(String result); +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java new file mode 100644 index 0000000000..fc5e31d14e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/MyServiceImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import org.osoa.sca.annotations.Callback; +import org.osoa.sca.annotations.Scope; +import org.osoa.sca.annotations.Service; + +/** + * This class implements MyService and uses a callback. + */ +@Service(MyService.class) +@Scope("COMPOSITE") +public class MyServiceImpl implements MyService { + + private MyServiceCallback myServiceCallback; + + /** + * The setter used by the runtime to set the callback reference + * @param myServiceCallback + */ + @Callback + public void setMyServiceCallback(MyServiceCallback myServiceCallback) { + this.myServiceCallback = myServiceCallback; + } + + public void someMethod(String arg) { + // invoke the callback + try { + myServiceCallback.receiveResult(arg + " -> receiveResult"); + } catch(RuntimeException e) { + System.out.println("RuntimeException invoking receiveResult: " + e.toString()); + } + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.java new file mode 100644 index 0000000000..b8987fcd07 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/java/simplecallback/SimpleCallbackClient.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 simplecallback; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Demonstrates resolving the client service and initiating the callback sequence + */ +public class SimpleCallbackClient { + + public static void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("simplecallback.composite"); + MyClient myClient = scaDomain.getService(MyClient.class, "MyClientComponent"); + + System.out.println("Main thread " + Thread.currentThread()); + myClient.aClientMethod(); + Thread.sleep(500); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/resources/simplecallback.composite b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/resources/simplecallback.composite new file mode 100644 index 0000000000..33e6f60601 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/main/resources/simplecallback.composite @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java new file mode 100644 index 0000000000..cbaab8af83 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/simple-callback/src/test/java/simplecallback/SimpleCallbackTestCase.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package simplecallback; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * A testcase that demonstrates resolving the client service and initiating the callback sequence + */ +public class SimpleCallbackTestCase extends TestCase { + + private SCADomain scaDomain; + private MyClient myClient; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("simplecallback.composite"); + myClient = scaDomain.getService(MyClient.class, "MyClientComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + System.out.println("Main thread " + Thread.currentThread()); + myClient.aClientMethod(); + System.out.println("Sleeping ..."); + Thread.sleep(300); + assertEquals("-> someMethod -> receiveResult", MyClientImpl.result); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/pom.xml new file mode 100644 index 0000000000..1bb4983999 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/pom.xml @@ -0,0 +1,59 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-spi-implementation-java + Apache Tuscany Java Implementation SPI Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-extension-helper + 0.99-incubating-SNAPSHOT + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java new file mode 100644 index 0000000000..73104c3166 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementation.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES 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 JavaImplementation { + + private String className; + + public String getClass_() { + return className; + } + + public void setClass_(String className) { + this.className = className; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java new file mode 100644 index 0000000000..43efae32ca --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaImplementationActivator.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.spi.ImplementationActivator; +import org.apache.tuscany.sca.spi.InvokerFactory; + +public class JavaImplementationActivator implements ImplementationActivator { + + public Class getImplementationClass() { + return JavaImplementation.class; + } + + public InvokerFactory createInvokerFactory(RuntimeComponent rc, ComponentType ct, JavaImplementation implementation) { + return new JavaInvokerFactory(rc, ct, implementation); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java new file mode 100644 index 0000000000..d65d4c8e4a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvoker.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package sample; + +import java.lang.reflect.Method; + +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.invocation.Message; +import org.osoa.sca.ServiceRuntimeException; + +public class JavaInvoker implements Invoker { + + protected Class clazz; + protected Object instance; + protected Operation operation; + + public JavaInvoker(Class clazz, Object instance, Operation operation) { + this.clazz = clazz; + this.instance = instance; + this.operation = operation; + } + + public Message invoke(Message msg) { + try { + msg.setBody(getMethod().invoke(instance, (Object[])msg.getBody())); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + return msg; + } + + protected Method getMethod() { + for (Method method : clazz.getMethods()) { + if (method.getName().equals(operation.getName())) { + return method; + } + } + throw new ServiceRuntimeException("no method found for operation: " + operation.getName()); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.java new file mode 100644 index 0000000000..198befa928 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/java/sample/JavaInvokerFactory.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; + +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.interfacedef.Operation; +import org.apache.tuscany.sca.invocation.Invoker; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.spi.InvokerFactory; +import org.osoa.sca.ServiceRuntimeException; + +public class JavaInvokerFactory implements InvokerFactory { + + protected Object instance; + protected Class clazz; + + public JavaInvokerFactory(RuntimeComponent rc, ComponentType ct, JavaImplementation implementation) { + try { + this.clazz = Class.forName(implementation.getClass_()); + this.instance = clazz.newInstance(); + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } + + public Invoker createInvoker(Operation operation) { + return new JavaInvoker(clazz, instance, operation); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator new file mode 100644 index 0000000000..95ee37c1aa --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.spi.ImplementationActivator @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# Implementation class for the ExtensionActivator +sample.JavaImplementationActivator diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java new file mode 100644 index 0000000000..cc32929f09 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorld.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +public interface HelloWorld { + + String sayHello(String name); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java new file mode 100644 index 0000000000..02af1ccf22 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldImpl.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package helloworld; + +public class HelloWorldImpl implements HelloWorld { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java new file mode 100644 index 0000000000..5813fda330 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/java/helloworld/HelloWorldTestCase.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package helloworld; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + */ +public class HelloWorldTestCase extends TestCase { + + public void testHello() throws Exception { + SCADomain scaDomain = SCADomain.newInstance("helloworld/helloworld.composite"); + HelloWorld helloworld = scaDomain.getService(HelloWorld.class, "HelloWorldComponent"); + assertEquals("Hello petra", helloworld.sayHello("petra")); + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite new file mode 100644 index 0000000000..fa9cecc160 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/spi-implementation-pojo/src/test/resources/helloworld/helloworld.composite @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/README b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/README new file mode 100644 index 0000000000..ea4493fdd4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/README @@ -0,0 +1,101 @@ +SupplyChain Sample +================== + +This sample demonstrates SCA components using the asynchronous API. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-supplychain.jar supplychain.SupplyChainClient + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-supplychain.jar supplychain.SupplyChainClient + + +Sample Overview +--------------- + +The sample provides a Customer service with a purchaseGoods operation +and a notifyShipment operation annotated with the SCA @OneWay annotation. +The SupplyChainClient exercises this interface by calling the +purchaseGoods operation. This results in messages passing to +the Retailer, Warehouse, and Shipper components and the result returned +to the Customer service on a separate callback thread. + +supplychain/ + src/ + main/ + java/ + supplychain/ + Customer.java - Defines the Java interface implemented + by the Customer component + CustomerComponentImpl.java - Implements the SCA Customer component + Retailer.java - Defines the Java interface implemented + by the Retailer component + RetailerComponentImpl.java - Implements the SCA RetailerComponent component + Shipper.java - Defines the Java interface implemented + by the Shipper component + ShipperComponentImpl.java - Implements the SCA ShipperComponent component + SupplyChainClient.java - SupplyChainClient.java loads SCA runtime + Warehouse.java - Defines the Java interface implemented + by the Warehouse component + WarehouseComponentImpl.java - Implements the SCA WarehouseComponent component + + resources/ + supplychain.composite - the SCA assembly for this sample + test/ + java/ + supplychain/ + SupplyChainClientTestCase.java - JUnit test case + 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 supplychain +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Main thread Thread[main,5,main] + [java] Main thread sleeping ... + [java] Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shipped + +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 supplychain +mvn + +You should see the following output from the test phase. + +------------------------------------------------------- + T E S T S +------------------------------------------------------- +Running supplychain.SupplyChainClientTestCase +Main thread Thread[main,5,main] +Sleeping ... +Work thread Thread[pool-1-thread-1,5,main] - Order, submitted, fulfilled, shipped +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.625 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. \ No newline at end of file diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/build.xml new file mode 100644 index 0000000000..506180b8b1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/build.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/pom.xml new file mode 100644 index 0000000000..85087e016a --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/pom.xml @@ -0,0 +1,65 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 0.99-incubating-SNAPSHOT + ../../pom.xml + + sample-supplychain + Apache Tuscany Supply Chain Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Customer.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Customer.java new file mode 100644 index 0000000000..8088001898 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Customer.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 supplychain; + +import org.osoa.sca.annotations.OneWay; + +/** + * This is the business interface of the Customer service component. + */ +public interface Customer { + + public void purchaseGoods(); + + @OneWay + public void notifyShipment(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java new file mode 100644 index 0000000000..7a1e8553ec --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/CustomerComponentImpl.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + +import org.osoa.sca.annotations.Reference; + +/** + * This class implements the Customer service component. + */ +public class CustomerComponentImpl implements Customer { + + private Retailer retailer; + + @Reference + public void setRetailer(Retailer retailer) { + this.retailer = retailer; + } + + public void purchaseGoods() { + retailer.submitOrder("Order"); + } + + public void notifyShipment(String order) { + System.out.print("Work thread " + Thread.currentThread() + " - "); + System.out.println(order); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Retailer.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Retailer.java new file mode 100644 index 0000000000..1add63fb4e --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Retailer.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + +/** + * This is the business interface of the Retailer service component. + */ +public interface Retailer { + + public void submitOrder(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.java new file mode 100644 index 0000000000..f622052cf8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/RetailerComponentImpl.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 supplychain; + +import org.osoa.sca.annotations.Reference; + +/** + * This class implements the Customer service component. + */ +public class RetailerComponentImpl implements Retailer { + + private Warehouse warehouse; + + @Reference + public void setWarehouse(Warehouse warehouse) { + this.warehouse = warehouse; + } + + public void submitOrder(String order) { + warehouse.fulfillOrder(order + ", submitted"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Shipper.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Shipper.java new file mode 100644 index 0000000000..d4d49a922b --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Shipper.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + +/** + * This is the business interface of the Shipper service component. + */ +public interface Shipper { + + public void processShipment(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.java new file mode 100644 index 0000000000..4ae52a12a2 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/ShipperComponentImpl.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 supplychain; + +import org.osoa.sca.annotations.Reference; + +/** + * This class implements the Warehouse service component. + */ +public class ShipperComponentImpl implements Shipper { + + private Customer customer; + + @Reference + public void setCustomer(Customer customer) { + this.customer = customer; + } + + public void processShipment(String order) { + customer.notifyShipment(order + ", shipped"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/SupplyChainClient.java new file mode 100644 index 0000000000..7072f582d1 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/SupplyChainClient.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 supplychain; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate a Customer service component and invoke it. + */ +public class SupplyChainClient { + + public static final void main(String[] args) throws Exception { + SCADomain scaDomain = SCADomain.newInstance("supplychain.composite"); + Customer customer = scaDomain.getService(Customer.class, "CustomerComponent"); + + System.out.println("Main thread " + Thread.currentThread()); + customer.purchaseGoods(); + System.out.println("Main thread sleeping ..."); + Thread.sleep(1000); + + scaDomain.close(); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Warehouse.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Warehouse.java new file mode 100644 index 0000000000..0be499f569 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/Warehouse.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package supplychain; + +/** + * This is the business interface of the Warehouse service component. + */ +public interface Warehouse { + + public void fulfillOrder(String order); + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.java new file mode 100644 index 0000000000..b5e256a1e0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/java/supplychain/WarehouseComponentImpl.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 supplychain; + +import org.osoa.sca.annotations.Reference; + +/** + * This class implements the Warehouse service component. + */ +public class WarehouseComponentImpl implements Warehouse { + + private Shipper shipper; + + @Reference + public void setShipper(Shipper shipper) { + this.shipper = shipper; + } + + public void fulfillOrder(String order) { + shipper.processShipment(order + ", fulfilled"); + } + +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/resources/supplychain.composite b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/resources/supplychain.composite new file mode 100644 index 0000000000..301efcaf1f --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/main/resources/supplychain.composite @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.java new file mode 100644 index 0000000000..88e0eb7ab8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/src/test/java/supplychain/SupplyChainClientTestCase.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 supplychain; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * This client program shows how to create an SCA runtime, start it, + * locate a the Customer service component and invoke it. + */ +public class SupplyChainClientTestCase extends TestCase { + + private SCADomain scaDomain; + private Customer customer; + + @Override + protected void setUp() throws Exception { + scaDomain = SCADomain.newInstance("supplychain.composite"); + customer = scaDomain.getService(Customer.class, "CustomerComponent"); + } + + @Override + protected void tearDown() throws Exception { + scaDomain.close(); + } + + public void test() throws Exception { + + System.out.println("Main thread " + Thread.currentThread()); + customer.purchaseGoods(); + System.out.println("Sleeping ..."); + Thread.sleep(1000); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.png b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.png new file mode 100644 index 0000000000..51a384e827 Binary files /dev/null and b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.png differ diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.svg b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.svg new file mode 100644 index 0000000000..f72e77acab --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/supplychain/supplychain.svg @@ -0,0 +1,228 @@ + + + + + + + + + + image/svg+xml + + + + + + + + supplychain + + CustomerComponent + + + RetailerComponent + + + WharehouseComponent + + + ShipperComponent + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/README b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/README new file mode 100644 index 0000000000..616cfc6af8 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/README @@ -0,0 +1,72 @@ +Web Resource Component Sample +====================================== +This sample demonstrates an SCA Web resource component. + +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 ..\..\lib\tuscany-sca-manifest.jar;target\sample-web-resource.jar web.resource.SampleServer + +and on *nix do + +java -cp ../../lib/tuscany-sca-manifest.jar:target/sample-web-resource.jar web.resource.SampleServer + +Now the server is started you can point your Web browser to the URL of the Web resource. + +Sample Overview +--------------- +The sample provides a single component exposing a Web resource. + +web-resource/ + src/ + main/ + java/ + web/resource/ + SampleServer.java - starts the SCA Runtime and + deploys the WebResource.composite + resources/ + myContent/ + index.html - a Web HTML resource + WebResource.composite - the SCA assembly for this sample + web-resource.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 using the +following commands + +cd web-resource +ant compile +ant run + +You should see the following output from the run target. + +run: + [java] Added Servlet mapping: http://localhost:8080/myWeb/* + [java] Sample server started (press enter to shutdown) + + [java] To get the Web resource, point your Web browser to the following address: + [java] http://localhost:8080/MyWeb/index.html + +As this point the Web resource is exposed by a web server started automatically +by the SCA runtime. To stop the server just press enter. + +Building The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built using +Maven as follows. + +cd web-resource +mvn + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/build.xml b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/build.xml new file mode 100644 index 0000000000..e337acb215 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/build.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/pom.xml b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/pom.xml new file mode 100644 index 0000000000..dc6be5c6a0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/pom.xml @@ -0,0 +1,79 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-samples + 0.99-incubating-SNAPSHOT + ../pom.xml + + sample-web-resource + Apache Tuscany Web Resource Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-host-embedded + 0.99-incubating-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-resource + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http + 0.99-incubating-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-http-tomcat + 0.99-incubating-SNAPSHOT + runtime + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/java/web/resource/SampleServer.java b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/java/web/resource/SampleServer.java new file mode 100644 index 0000000000..9410de08c4 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/java/web/resource/SampleServer.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package web.resource; + +import java.io.IOException; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +public class SampleServer { + public static void main(String[] args) throws Exception { + + SCADomain scaDomain = SCADomain.newInstance("WebResource.composite"); + + try { + System.out.println("Sample server started (press enter to shutdown)"); + System.out.println(); + System.out.println("To get the Web resource, point your Web browser to the following address:"); + System.out.println("http://localhost:8080/myWeb/index.html"); + System.out.println(); + System.in.read(); + } catch (IOException e) { + e.printStackTrace(); + } + + scaDomain.close(); + System.out.println("Sample server stopped"); + } +} diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/WebResource.composite b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/WebResource.composite new file mode 100644 index 0000000000..2376e79bf0 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/WebResource.composite @@ -0,0 +1,32 @@ + + + + + + + + + + + + diff --git a/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/myContent/index.html b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/myContent/index.html new file mode 100644 index 0000000000..c6ea59af55 --- /dev/null +++ b/sca-java-1.x/branches/sca-java-0.99/samples/web-resource/src/main/resources/myContent/index.html @@ -0,0 +1,49 @@ + + + + Tuscany Sample Web Resource + + + +

A Sample Web Resource

+ +

Tuscany allows you to publish Web resources using SCA components declared with an + <implementation.resource> component implementation type and made available + to HTTP clients using a <binding.http> binding.

+ +

Here is the SCA composite that publishes this page:

+ +
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+  targetNamespace="http://web"
+  name="WebResource">
+
+  <component name="myWeb">
+    <service name="Resource">
+      <binding.http/>
+    </service>
+    <implementation.resource location="myContent"/>
+  </component>      
+
+</composite>
+  	
+ + + -- cgit v1.2.3